Create TextViews with same width in TableRow - android

I'm facing a problem: I'd like to create a grid of icons for my main screen and so I'm using 4 TableRows and 3 TextViews in each.
The TextViews are made of an icon and a text, the text is of different length.
I don't know what to write in the xml file to make all those TextViews the same width in a row.
I displayed their size in logcat so I'm sure they're not of the same width ;)
I've tried m1shk4's solution, but that doesn't work.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true" >
<TableRow
android:id="#+id/tableRow1"
android:layout_weight="1"
android:gravity="center" >
<TextView
android:id="#+id/textView1"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="match_parent"
android:clickable="true"
android:drawableTop="#drawable/nearby"
android:gravity="center"
android:onClick="goToArticles"
android:text="All Nearby" />
<TextView
android:id="#+id/textView2"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:layout_width="match_parent"
android:drawableTop="#drawable/supermarket"
android:gravity="center"
android:onClick="goToMap"
android:text="Supermarkets" />
<TextView
android:id="#+id/textView3"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="match_parent"
android:drawableTop="#drawable/pharmacy"
android:gravity="center"
android:text="Pharmacy" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_weight="1"
android:gravity="center" >
<TextView
android:id="#+id/textView4"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="match_parent"
android:drawableTop="#drawable/fastfood"
android:gravity="center"
android:text="Fastfood" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:drawableTop="#drawable/departmentstores"
android:gravity="center"
android:onClick="displaySizes"
android:text="Department Stores" />
<TextView
android:id="#+id/textView6"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="match_parent"
android:drawableTop="#drawable/petrol"
android:gravity="center"
android:text="Petrol Stations" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_weight="1"
android:gravity="center" >
<TextView
android:id="#+id/textView7"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="#drawable/electronics"
android:gravity="center"
android:layout_width="match_parent"
android:text="Electronics" />
<TextView
android:id="#+id/textView8"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="match_parent"
android:drawableTop="#drawable/diy"
android:gravity="center"
android:text="DIY Stores" />
<TextView
android:id="#+id/textView9"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="match_parent"
android:drawableTop="#drawable/banking"
android:gravity="center"
android:text="Banks" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_weight="1"
android:gravity="center" >
<TextView
android:id="#+id/textView10"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="match_parent"
android:drawableTop="#drawable/fashion"
android:gravity="center"
android:text="Fashion & Clothing" />
<TextView
android:id="#+id/textView11"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="match_parent"
android:drawableTop="#drawable/autoparts"
android:gravity="center"
android:text="Auto Service" />
<TextView
android:id="#+id/textView12"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="match_parent"
android:drawableTop="#drawable/more"
android:gravity="center"
android:text="All Categories" />
</TableRow>
</TableLayout>
Any idea?
Thanks :)

Since TableRow represents a horizontally oriented LinearLayout, the weight attribute should be used with layout_width="0dp" for the child views. So in order to make each TextView in the TableRow be same width replace
android:layout_width="match_parent"
with
android:layout_width="0dp"
for every TextView in a row.

Related

A Timetable that show ongoing Activities( eg Classes, Testes ) within a Week

How to display schedule like (Classes, Testes and so on) for college App Using a Timetable, for eg like this
I was thinking of extending FrameLayout and customize it in some way, Any help?
Thanks.
You can use TableLayout to design the desired view. According to documentation TableLayout is A layout that arranges its children into rows and columns. This I think is the best suit for you` as you have given number of rows and columns.
Here is an example of TableLayout you can extend to fit your needs:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<TableRow android:background="#0079D6" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="title 1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="title 2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="title 3" />
</TableRow>
<TableRow android:background="#DAE8FC" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Suresh Dasari" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Hyderabad" />
</TableRow>
<TableRow android:background="#DAE8FC" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Rohini Alavala" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Guntur" />
</TableRow>
<TableRow android:background="#DAE8FC" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Trishika Dasari" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Guntur" />
</TableRow>

Can't adjust weights in linear layout - android

I've searched but couldn't figure out the problem.
I want to make exactly like the above picture. I've used linear layout in vertical for the "Day Teams Score Status"
And then for the content containing the values of above headings, I've used a listview.
What I've achieved is that headings "Day Teams Score Status" are being shown with spaces but the contents ( which are in seperate .xml file ) are not being shown with spaces, so what I'm getting is:
The adapter xml file for the list view is:
adapter_my_matches.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Date"
android:id="#+id/textViewDate"
android:layout_weight="0.1"
android:layout_gravity="center_vertical" />
<LinearLayout
android:id="#+id/ll"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.4">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Teams"
android:id="#+id/textViewTeams1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Teams"
android:id="#+id/textViewTeams2"/>
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Score"
android:id="#+id/textViewScore"
android:layout_weight="0.1"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Status"
android:id="#+id/textViewStatus"
android:layout_weight="0.2"
android:layout_gravity="center_vertical" />
</LinearLayout>
I think this is the layout you are looking for.Let me know if anything going bad. Here the weight i set for a sample, you can change it according to your need.
<?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="vertical"
>
<LinearLayout
android:id="#+id/ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum= "6">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Date"
android:id="#+id/textViewDate"
android:layout_weight="1.2"
android:gravity="center" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Teams"
android:id="#+id/textViewTeams1"
android:gravity="center"
android:layout_weight="2"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Score"
android:id="#+id/textViewScore"
android:layout_weight="1.4"
android:gravity="center"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Status"
android:id="#+id/textViewStatus"
android:layout_weight="1.4"
android:gravity="center"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/ll1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum= "6">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="12 Feb"
android:id="#+id/textViewDate1"
android:layout_weight="1.2"
android:gravity="center" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="IND VS PAK"
android:id="#+id/textViewTeams11"
android:gravity="center"
android:layout_weight="2"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="256"
android:id="#+id/textViewScore1"
android:layout_weight="1.4"
android:gravity="center"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="WIN"
android:id="#+id/textViewStatus1"
android:layout_weight="1.4"
android:gravity="center"
/>
</LinearLayout>
</LinearLayout>
Add this to your linearlayout code
android:weightSum="0.8"
Use this One :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="8" >
<TextView
android:id="#+id/textViewDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="Date"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:id="#+id/ll"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:orientation="vertical" >
<TextView
android:id="#+id/textViewTeams1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Teams"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textViewTeams2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Teams"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<TextView
android:id="#+id/textViewScore"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="Score"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textViewStatus"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:text="Status"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
give layout_weight to parent layout and give weight to child element and make sure that layout_weight should be sum of its all child's weight total. make width of child as warp_content.

Stretch one column, shrink others in Android TableLayot

Below I would like to strech the pool_team column and have the others shrink to the column width. I can't seem to get it right though. The other columns will contain an integer of small size and the pool_team will contain a long name that may wrap.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pool_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1"
android:shrinkColumns="0">
<TableRow
android:id="#+id/pool_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/pool_number"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:textAlignment="center" />
<TextView
android:id="#+id/pool_team"
android:layout_width="0dip"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/pool_wins"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:textAlignment="center" />
<TextView
android:id="#+id/pool_loses"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:textAlignment="center" />
<TextView
android:id="#+id/pool_point_difference"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:textAlignment="center" />
<TextView
android:id="#+id/pool_place"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:textAlignment="center" />
</TableRow>
</TableLayout>
Something like this?
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pool_table"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/pool_row"
android:weightSum="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView
android:id="#+id/pool_number"
android:layout_width="0dp"
android:layout_weight=".1"
android:layout_height="wrap_content"
android:gravity="center"
android:text="123" />
<TextView
android:id="#+id/pool_team"
android:layout_width="0dp"
android:layout_weight=".5"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Some longer text that may or may not wrap around to the next line...." />
<TextView
android:id="#+id/pool_wins"
android:layout_weight=".1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="123" />
<TextView
android:id="#+id/pool_loses"
android:layout_weight=".1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="123" />
<TextView
android:id="#+id/pool_point_difference"
android:layout_width="0dp"
android:layout_weight=".1"
android:layout_height="wrap_content"
android:gravity="center"
android:text="123" />
<TextView
android:id="#+id/pool_place"
android:layout_weight=".1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="123" />
</TableRow>

Table layout column spacing

I am trying to format my tablelayout but I dont seem to get things working quite well.
I have 4 columns that I need them spaced as nice as possible. I was thinking really having 3 columns with same width and the last column taking the rest of the space. The last column is ok to wrap around in 2 or more lines but the first 3 columns has to be single line and NOT truncated. Here is my code
<TableLayout android:id="#+id/tlMylayout" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:stretchColumns="*" android:shrinkColumns="*" >
<TableRow android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="#style/showtext_style" android:text="col1" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="#style/showtext_style" android:text="col2" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="#style/showtext_style" android:text="col3" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="#style/showtext_style" android:text="lastCol" />
</TableRow>
<TableRow android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content"android:text="2011-01-01 14:59" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:text="50" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:text="0.57" />
<TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="this is the last one and can be very long string if I want it to be" />
</TableRow>
</TableLayout>
Try
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tlMylayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:shrinkColumns="*"
android:stretchColumns="*" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="col1" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="col2" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="col3" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="lastCol" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="2011-01-01 14:59" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:singleLine="true"
android:text="50" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:singleLine="true"
android:text="0.57" />
<TextView
android:layout_width="0"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:gravity="center"
android:text="this is the last one and can be very long string if I want it to be" />
</TableRow>
I removed layout_gravity and added layout_weight to TextView

Android: making a simple layout

I would like to construct a simple table layout in Android BUT I got some problems with it.
At part 1: there are some text views so I would like to put that TableRow's height to wrap_content.
At part 2: same thing.
It works all still now BUT:
At part 3: there are 2 listview-s and at part 4 there are some buttons.
I would like to do something like this:
let the part 4's height to wrap content but make the part 3 to fill all the empty space on the screen.
Please give me a solution for this, beacause when i probed the part 3 filled out all the emty space till the bottom of the screen. Now I tryed with weight_sum BUT I do not like it because I would let the 4'd row to wrap_content.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/black"
android:weightSum="1.0" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:weightSum="1.0" >
<TextView
android:id="#+id/phone_tab_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:background="#layout/style_right_border"
android:gravity="center"
android:singleLine="true"
android:text="Phone Tab"
android:textColor="#android:color/white"
android:textSize="14dp" />
<TextView
android:id="#+id/pc_tab_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:gravity="center"
android:singleLine="true"
android:text="PC Tab"
android:textColor="#android:color/white"
android:textSize="14dp" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#layout/style_bottom_border" >
<TextView
android:id="#+id/phone_path_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:background="#layout/style_bott_right_border"
android:gravity="center"
android:paddingBottom="5dp"
android:singleLine="true"
android:text="mnt/sdcard/Movies/dpad/sadas/asda/sda/as"
android:textColor="#android:color/white"
android:textSize="8dp" />
<TextView
android:id="#+id/pc_path_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:gravity="center"
android:paddingBottom="5dp"
android:singleLine="true"
android:text="mnt/sdcard/Movies/dpad/sadas/asda/sda/as"
android:textColor="#android:color/white"
android:textSize="8dp" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.9"
android:weightSum="1.0" >
<ListView
android:id="#+id/listview_phone_files"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:background="#layout/style_right_border" />
<ListView
android:id="#+id/listview_pc_files"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.1"
android:background="#layout/style_top_border"
android:gravity="center"
android:weightSum="1.0" >
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="Button" />
<ImageButton
android:id="#+id/button_active_tab_changer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:background="#android:color/transparent"
android:onClick="changeActiveTabButton"
android:src="#drawable/button_change_tab" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="Button" />
</TableRow>
Create a RelativeLayout as parent and place the TableLayouts inside that. That allows you to use alignParentBottom and alignParentTop layaout params.
check it this layout, but please keep your old layout file in backup.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/black"
android:weightSum="1.0" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:weightSum="1.0" >
<TextView
android:id="#+id/phone_tab_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:gravity="center"
android:singleLine="true"
android:text="Phone Tab"
android:textColor="#android:color/white"
android:textSize="14dp" />
<TextView
android:id="#+id/pc_tab_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:gravity="center"
android:singleLine="true"
android:text="PC Tab"
android:textColor="#android:color/white"
android:textSize="14dp" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/phone_path_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:gravity="center"
android:paddingBottom="5dp"
android:singleLine="true"
android:text="mnt/sdcard/Movies/dpad/sadas/asda/sda/as"
android:textColor="#android:color/white"
android:textSize="8dp" />
<TextView
android:id="#+id/pc_path_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:gravity="center"
android:paddingBottom="5dp"
android:singleLine="true"
android:text="mnt/sdcard/Movies/dpad/sadas/asda/sda/as"
android:textColor="#android:color/white"
android:textSize="8dp" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1" >
<ListView
android:id="#+id/listview_phone_files"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" />
<ListView
android:id="#+id/listview_pc_files"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.1"
android:gravity="center"
android:weightSum="1.0" >
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="Button" />
<ImageButton
android:id="#+id/button_active_tab_changer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:background="#android:color/transparent"
android:onClick="changeActiveTabButton"
android:src="#android:drawable/ic_delete" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="Button" />
</TableRow>
</TableLayout>
set tableRow3's android:layout_height to 0, and android:layout_weight to 1. The other tableRows can use android:layout_height="wrap_content".

Categories

Resources