I'm trying to put 1 Button and 1 listviews into my layout. The problem is that . The first Button could have a few items (0,to 5) and the second listview could have 1 listviews ,It depends upon on Each Button Click.i Dont Know how to Split the screen?
My Images,
Use two LinearLayout having height fill_parent and orientation should be vertical. and width should be defined by you depending upon your requirement. Hope this may help you.
Use android:layout_weight to set the ratio of the elements.
Edit: I attached the basic layout you need, it only contains the splitted UI.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/tableLayout1"
android:layout_weight="2" >
<TableRow android:id="#+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="Mobilizitaion" android:id="#+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<Spinner android:id="#+id/spinner1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Spinner>
</TableRow>
<TableRow android:id="#+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="Main" android:id="#+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<Spinner android:id="#+id/spinner2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Spinner>
</TableRow>
<TableRow android:id="#+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="Services" android:id="#+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<Spinner android:id="#+id/spinner3" android:layout_width="wrap_content" android:layout_height="wrap_content"></Spinner>
</TableRow>
<TableRow android:id="#+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="Etc" android:id="#+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<Spinner android:id="#+id/spinner4" android:layout_width="wrap_content" android:layout_height="wrap_content"></Spinner>
</TableRow>
</TableLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
</LinearLayout>
</LinearLayout>
When the view creates only the list is visible, after I click one of the list item the screen ratio is set to 1:2.
Here is the xml:
<FrameLayout
android:id="#+id/fragment_list"
android:layout_weight="0"
android:layout_width="fill_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="#+id/framelayout_for_right_fragment"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0" />
This is the java code to set the ratio of the fragments.
final FrameLayout leftFragment = (FrameLayout) findViewById(R.id.fragment_list);
leftFragment.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 2));
final FrameLayout rightFragment = (FrameLayout) findViewById(R.id.framelayout_for_right_fragment);
rightFragment.setAnimation(AnimationHelper.inFromRight());
rightFragment.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1));
Related
mLayout :
ListView
i want to set mChartView to match_parent (fit screen)
and then add ListView below mChartView
but this only show mChartView
i try set fixed size to mChartView and ListView is work !. but i can't set mChartView to fit another screen size.
my mChartView and ListView using ScrollView
(code below it's work but mChart not match_parent because fixed size)
<ScrollView
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/tv_units"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:text="#string/label_data_baht"
android:textColor="#color/white"
android:textSize="16sp" />
<LinearLayout
android:id="#+id/ll_chart"
android:layout_width="match_parent"
android:layout_height="400dp" // fixed size
android:layout_margin="10dp"
android:orientation="vertical">
<com.github.mikephil.charting.charts.BarChart
android:id="#+id/mBarChart"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.github.mikephil.charting.charts.BarChart>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<ImageView
android:layout_width="18dp"
android:layout_height="8dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/bg_ic_saving" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tv_saving"
android:textColor="#ffffff"
android:textSize="13sp" />
<ImageView
android:layout_width="18dp"
android:layout_height="8dp"
android:layout_marginLeft="22dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/bg_ic_expense"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="33dp"
android:text="#string/tv_expense"
android:textColor="#ffffff"
android:textSize="13sp" />
</LinearLayout>
</RelativeLayout>
<ListView
android:id="#+id/BillListYearly"
android:layout_width="match_parent"
android:layout_height="400dp" // fixed size
android:layout_marginTop="20dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_gravity="center_horizontal"
android:focusable="false">
</ListView>
</LinearLayout>
</ScrollView>
thank you.
(I apologize for not being word-perfect in English)
Add property android:layout_weight="1" to LinearLayout of your chart view.
Also make it match_parent for height attribute,
make your ListView match_parent for height attribute.
I am designing a layout for an activity where some contents like Textview, spinner and buttons are arranged in the upper part of the screen. I want to position image view to the bottom of the screen with a match_parent attribute to fill to the remaining bottom of the screen and it has become a challenge to me as the image view is filling to the bottom of the remaining part of the screen. This is the entire layout of the upper section/part of the screen
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="fill_parent"
android:background="#drawable/xxxVal"
android:padding="10dp"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="#+id/dataVaues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="25sp"
android:gravity="center_horizontal"
android:textColor="#000"
/>
<Spinner
android:id="#+id/spinBundle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6sp"
android:textColor="#000"
android:prompt="#string/_prompt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="#000"
android:text="Plan" />
<TextView
android:id="#+id/bundle"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textSize="30sp"
android:textColor="#000"/>
<!-- android:inputType="phone" -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="#000"
android:text="PValue:" />
<TextView
android:id="#+id/value"
android:inputType="value"
android:layout_height="wrap_content"
android:textSize="30sp"
android:layout_width="match_parent"
android:textColor="#000"/>
<TextView
android:id="#+id/validValue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Valid:"
android:textColor="#000000" />
<TextView
android:id="#+id/valid"
android:inputType="valid"
android:layout_height="wrap_content"
android:textSize="30sp"
android:layout_width="match_parent"
android:layout_marginBottom="10dp"
android:textColor="#ff0000"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<Button
android:id="#+id/proceed"
android:text="Proceed"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textColor="#000"/>
<Button
android:id="#+id/data"
android:text="Check"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginTop="10dp"
android:textColor="#000"/>
</LinearLayout>
this is remaining part of the layout with a view flipper for an image that I want it to fit down to the remaining part of the screen but its not fitting as it shrinks up
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="3dp"
android:gravity="center_horizontal"
android:orientation="vertical" >
<ViewFlipper
android:id="#+id/flipper1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:flipInterval="5000"
android:inAnimation="#anim/slide_in_right"
android:outAnimation="#anim/slide_out_left" >
</ViewFlipper>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
please kindly assist!
Try adding the imageview to the Viewflipper like so:
<ViewFlipper
android:id="#+id/simpleViewFlipper"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src=IMAGE />
</ ViewFlipper >
Having said that you might find some issues regarding swiping when using a viewflipper inside a scrollview
I just want to center "CenterButton" (center of the root LinearLayout) but Androids just not cooperating..
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="center_horizontal"
android:layout_weight="0.00"
android:padding="5dp"
android:background="#zegerg"
android:id="#+id/LinearLayout1">
<ImageView
android:id="#+id/ImageView1"
android:layout_height="match_parent"
android:layout_width="151dp"
android:src="#mipmap/image_1"
android:contentDescription="#string/abcdef"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:id="#+id/CenterButton"
android:layout_gravity="center_horizontal|center_vertical|center"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text !"
android:id="#+id/TextView"
android:paddingBottom="30dp"
android:textColor="#37a52c" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/ProgressBar"
android:paddingBottom="30dp"
android:progressTint="#37a52c" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/text_text"
android:id="#+id/Button2"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</LinearLayout>
Tried putting it at the end of the XML but doesn't work because the other elements push it aside.. not really sure what's happening.
if you want to have all three first level children to be in equally-sized columns, then you need to add to all of them the followings attribute:
android:layout_width="0dp"
android:layout_weight="1"
(don't forget the dimension "dp" to the width parameter, otherwise the IDE will complain).
...
<ImageView
android:id="#+id/ImageView1"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:src="#mipmap/image_1"
android:contentDescription="#string/abcdef"/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Button"
android:id="#+id/CenterButton"
android:layout_gravity="center_horizontal|center_vertical|center"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:padding="20dp">
....
EDITED:
If you want your CenterButton to overlap all the other views, then what you have to do is:
wrap everything in a relative layout with height equal to 200dp, as its first child
remove the button CenterButton from the current position and add it at the bottom of everything, still inside the relative layout, but below the linear layout
add those properties to the button to make it center in the parent
android:layout_centerInParent="true"
So finally you will have something like this (I have changed some resources):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="center_horizontal"
android:layout_weight="0.00"
android:padding="5dp"
android:background="#android:color/holo_orange_dark"
android:id="#+id/LinearLayout1">
<ImageView
android:id="#+id/ImageView1"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:src="#drawable/plus"
android:contentDescription="abcdef"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:padding="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text !"
android:id="#+id/TextView"
android:paddingBottom="30dp"
android:textColor="#37a52c" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/ProgressBar"
android:paddingBottom="30dp"
android:progressTint="#37a52c" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text"
android:id="#+id/Button2"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Button"
android:id="#+id/CenterButton"
android:layout_gravity="center_horizontal|center_vertical|center"/>
</RelativeLayout>
You can use weight for such purposes for child items. Make layout_width for all of them as 0dp and set layout_weight as 1.
Give the three children in the topmost linear layout a gravity of 1 and a width of 0.
It's not clear what exactly is your problem. However, here are some general notes :
To center a View or a Layout inside RelativeView use layout_centerInParent="true"
To make a Layout on top of other layouts use FrameLayout
The order of the views/layouts in your xml file is important. The one you write the last will be on the top (in our example : the FrameLayout or just the CenterButton should be written after the other views and layouts in your xml file)
To distribute the available space inside LinearLayout among its views use android:layout_weight="1" (change the value according to your needs)
you can play aground with this example :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="200dp">
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#fff"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="#+id/ImageView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:src="#mipmap/ic_launcher" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:orientation="vertical">
<TextView
android:id="#+id/TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="30dp"
android:text="Text !"
android:textColor="#37a52c" />
<ProgressBar
android:id="#+id/ProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="30dp"
android:progressTint="#37a52c" />
<Button
android:id="#+id/Button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text_text" />
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<Button
android:id="#+id/CenterButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical|center"
android:text="Button" />
</FrameLayout>
</RelativeLayout>
I have a ListView with my own XML. It contains a TextView. There can be 1 up to 6 lines of text.
The problem is that it shows only 2 lines of text. How can I change the size of an item in a ListView dynamically to show the whole text?
My xml, where txt2 contains 1-6 line of text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="Test"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="#+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18dp"
android:textColor="#000000"
/>
<TextView
android:id="#+id/txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="#000000"
/>
</LinearLayout>
</LinearLayout>
Try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="Test"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="#+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18dp"
android:textColor="#000000"
/>
<TextView
android:id="#+id/txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="#000000"
/>
</LinearLayout>
Use for Textview
android:singleLine="false"
Use this to calculate dynamically change
String abc ="text which you will use";
TextView textView = null; // assign here
textView.setMaxLines(abc.length()/ 40);
textView.setMinLines(abc.length()/ 40);
Make your list view to be horizontally scrollable
i.e.
Add your
<ListView> inside <HorizontalScrollView>
Now you can horizontally scroll to see full text...
You can also Just give a fixed
layout_width for TextView.
And the whole 1-6 lines of text will wrap to according to height...
My Android app has a table with seven columns. I'd like to change the background color of these columns when the content in the table is updated. How do I specify columns in the main.xml and how do I change their background color? Thanks.
Edit main.xml posted...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#CDCDCD" android:orientation="vertical">
<TableLayout android:id="#+id/tableLayout1" android:layout_width="match_parent" android:layout_height="wrap_content">
<TableRow android:id="#+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="100" android:id="#+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="1"></TextView>
<TextView android:text="100" android:id="#+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="2"></TextView>
<TextView android:text="100" android:id="#+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="3"></TextView>
<TextView android:text="100" android:id="#+id/textView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="4"></TextView>
<TextView android:text="100" android:id="#+id/textView6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="5"></TextView>
<TextView android:text="100" android:id="#+id/textView7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="6"></TextView>
<TextView android:text="100" android:id="#+id/textView8" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="7"></TextView>
</TableRow>
<TableRow android:id="#+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="100" android:id="#+id/textView11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="1"></TextView>
<TextView android:text="100" android:id="#+id/textView12" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="2"></TextView>
<TextView android:text="100" android:id="#+id/textView13" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="3"></TextView>
<TextView android:text="100" android:id="#+id/textView14" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="4"></TextView>
<TextView android:text="100" android:id="#+id/textView15" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="5"></TextView>
<TextView android:text="100" android:id="#+id/textView16" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="6"></TextView>
<TextView android:text="100" android:id="#+id/textView17" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="7"></TextView>
</TableRow>
</TableLayout>
</LinearLayout>
EDIT:
This is an example of why I want to highlight the entire column instead of the individual textviews. When I highlight the individual textviews they are different sizes so they do not expand to the width of the widest textview in that column. Unless anyone knows how to change the size of my text views to fit the size of the widest textview in each column. If anyone does know this, please post.
EDIT:
Results of adding layout_weight properties to the TableRow tag...
I also tried the same thing but added the layout_weight property to the TextView tag instead. Here is the result...
To give your textviews equal width and therefore fix your higlighting issue you should look at the layout_weight property
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#CDCDCD"
android:orientation="vertical">
<TableLayout android:id="#+id/tableLayout1" android:layout_width="match_parent" android:layout_height="wrap_content">
<TableRow
android:id="#+id/tableRow1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5">
<TextView android:text="100" android:id="#+id/textView2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_column="1"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5">
<TextView android:text="100" android:id="#+id/textView11" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_column="1"></TextView>
</TableRow>
</TableLayout>
</LinearLayout>
Now I'm not at my development PC so can't verify this (and fix my formatting), but it should work I'll check it later.
Maybe not the prettiest solution but you could change the background color of all the TextViews in the column.
TextView textview2 = (TextView) findViewById(R.id.textView2);
TextView textview11 = (TextView) findViewById(R.id.textView11);
textview2.setBackgroundColor(Color.RED);
textview11.setBackgroundColor(Color.RED);
I ended up using a series of nested linear layouts, a full-screen horizonal one with evenly spaced vertical ones for the columns. If I then set the TextView background to transparent, I can change the entire column background by setting the background of the column's LinearLayout.