ScrollView a TableLayout inside a TabHost - android

I am trying to scroll a TableLayout that is nested inside a Tab. I can scroll the Table as intended but the problem is that the Table when scrolls up, it shows up behind the Tab as it scrolls.
I want to make just the Table part of the Layout to scroll.
At the end there is a RelativeLayout which serves as a legend(Key Guide) of the information that I will show dynamically in the form of rows inside the Table. SO it needs to be at the bottom of the screen and should not scroll like the table itself. But in this code everything below the Tab scrolls up (except the RelativeLayout)
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAligned="false"
android:orientation="vertical">
//Fixed On Screen
<TabHost
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TabWidget>
//Fixed On Screen
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:padding="4dp" >
<TextView
style="#android:style/TextAppearance.Medium"
android:layout_weight="1"
android:text="#string/start"
android:textStyle="bold"
android:typeface="serif" />
<TextView
style="#android:style/TextAppearance.Medium"
android:layout_weight="1"
android:text="#string/end"
android:textStyle="bold"
android:typeface="serif" />
<TextView
style="#android:style/TextAppearance.Medium"
android:layout_weight="1"
android:paddingLeft="5dp"
android:text="#string/effect"
android:textStyle="bold"
android:typeface="serif" />
</TableRow>
</TableLayout>
</LinearLayout>
//Scroll this content inside the Tab ONLY
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableLayout
android:id="#+id/Tab1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="4dp"
android:stretchColumns="*" >
</TableLayout>
<TableLayout
android:id="#+id/Tab2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="4dp"
android:stretchColumns="*" >
</TableLayout>
</LinearLayout>
</ScrollView>
</FrameLayout>
</TabHost>
//Fixed On Screen at the very bottom so the area between this and Tab is what scrolls
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#color/green"
android:padding="5dp"
android:text="#string/excellent"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#color/light_blue"
android:padding="5dp"
android:text="Good"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#color/dark_gray"
android:padding="5dp"
android:text="#string/normal"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#color/red"
android:padding="5dp"
android:text="Bad"
android:textColor="#FFFFFF" />
</TableRow>
</RelativeLayout>
In short, I want the following to be fixed on screen:
The Tab
The First TableLayout
The Last RelativeLayout
And want only the middle FrameLayout/TableLayout to Scroll. This layout will be filled with rows dynamically.
I have a feeling that it is as simple as maybe a wrap_content or fill_parent maybe. But can't seem to figure this out.
Thanks!

Related

How to add multiple buttons at the bottom of the screen in ListActivity

Question Edited :
I have added buttons at the bottom of screen now my listview is overlapping buttons in spite of putting scroll view. How can i limit my scroll view till button. Below is screenshot and code
Code edited as per suggestion
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<View
android:id="#+id/separator"
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_below="#android:id/tabs" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/btnSend"
android:layout_below="#+id/separator" >
<!-- Scrollview for message data -->
<ScrollView
android:id="#+id/formTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical" >
<LinearLayout
android:id="#+id/formLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="5dip" />
</LinearLayout>
</ScrollView>
</FrameLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tabcontent"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/add_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:text="Home" />
<Button
android:id="#+id/back_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:text="Messages" />
<Button
android:id="#+id/back_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:text="History" />
<Button
android:id="#+id/back_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:text="Settings" />
<Button
android:id="#+id/back_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:text="Support" />
</LinearLayout>
</RelativeLayout>
</TabHost>
You may want to use ListView#addFooterView() to add a View at the bottom of the ListView.
Add android:layout_below="#+id/tabcontent" to your Button instead of declaring that the FrameLayout is above the Button, because XML is read from top to bottom, so when the definitions for the FrameLayout are read, there is no Button yet, which means it can't be "above" it.

TextView under two list views

I've tried various solutions asked here on stackoverflow for the same problem but nothing is working for me. I want to display two text views under two list views. My code is this
<LinearLayout
....>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="2" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<ListView
android:id="#+id/lv1InBS"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
<ListView
android:id="#+id/lv2InBS"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:text="TextView"
android:textColor="#800000"
android:typeface="serif" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:text="TextView"
android:textColor="#800000"
android:typeface="serif" />
</LinearLayout>
</LinearLayout>
....
Please help. I've been sick trying to correct it.
Thanks.
ok you should try this methodology,
first take a simple linear layout with vertical orientation,
than add two list view and two text views in the way you want it on the screen,
than go to grafical editor and select first component, either listview or text view than click on the distribute waight evenly button given on the upper panel of the graphical editor.
This will work for sure.
<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="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:id="#+id/welcome"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="#string/hello_world" />
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</ListView>
<ListView
android:id="#+id/listView2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</ListView>
<TextView
android:id="#+id/welcome"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="#string/hello_world" />
<TextView
android:id="#+id/welcome"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="#string/hello_world" />
add this in your xml and have a look,because it is working for me.
Ok , here is a way to do it, by combining the Weight attribute of android views and Horizontal/Vertical LinearLayouts
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ListView
android:id="#+id/ListView01"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</ListView>
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</ListView>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
The first Horizontal Linearlayout acts as a container for the two parallel rows.
inside each row there are two vertical layouts ( by using equal weights and *layout_width="0"*) the layouts would split the screen in half.
Inside each LinearLayout a listView item (with height set to zero and weight to 1) and a textview item with any values you want.

How to make the last TableRow visible?

Picture of the android interface: http://tinypic.com/view.php?pic=avht6w&s=6
As seen in the picture above I want a small borders at the bottom and top of the white listView. The problem is, as I set the tableRow to be android:paddingBottom="20dp" the border never gets displayed at the bottom. It seems like, if the listviews height is big enough, nothing else after it will get displayed (See code example below to understand).
I have tested some different approaches to solve the problem, one is setting the paddingBottom attribute in the next TableRow (the borders tableRow) but it will only work if the listView's height is exact of the screens height and not to big.
Why do I set the listView's height to a fixed number like 415dp? Well, it is due to another problem I do not know how to solve. If I for example set the listViews height to fill_parent the background will only cover the number of items in the list. I always want the lists background to be filled down to 20dp from the bottom of the interface.
If anyone has some ideas how I can managed to display the border at the bottom and always have the lists background visible, even if it is not filled with items, please post your ideas! /thanx alot!
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/orginalbild"
android:gravity="center|top"
android:stretchColumns="1"
android:weightSum="1.0"
android:fillViewport="true">
<TableRow
android:background="#000000"
>
<TextView
android:layout_marginTop="0.15dp"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#999999"
android:layout_weight="1">
</TextView>
</TableRow>
<TableRow
android:background="#999999"
>
<TextView
android:background="#999999"
android:id="#+id/show_task_feedback_title"
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_weight="0.8"
android:text="#string/LatestFeedbackTitle"
android:textColor="#ffffff"
android:textSize="17dp"
android:shadowColor="#FFFFFF"
android:layout_marginBottom="0.15dp"
android:textAppearance="?android:attr/textAppearanceMedium">
</TextView>
<TextView
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_gravity="center"
android:layout_weight="0.08" >
</TextView>
<Button
android:id="#+id/latest_feedback_help_button"
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_gravity="center"
android:background="#drawable/help_button"
android:layout_weight="0.12"
android:layout_marginBottom="0.15dp"
/>
</TableRow>
<TableRow
android:background="#212421">
<TextView
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#ffffff"
android:layout_marginTop="0.15dp"
android:layout_weight="1">
</TextView>
</TableRow>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
</TableRow>
<TableRow
android:paddingLeft="24dp"
android:paddingRight="24dp"> <--------THE BLACK BRODER AT THE TOP OF THE LISTVIEW
<TextView
android:background="#000000"
android:layout_width="0dip"
android:layout_height="0.5dp"
android:layout_weight="1" >
</TextView>
</TableRow>
<TableRow
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingBottom="20dp" <------(paddingBottom attribute which causes the problem)
>
<ListView
android:background="#ffffff"
android:id="#+id/bookmarks_list"
android:layout_width="0dip"
android:layout_height="415dp"
android:gravity="left"
android:layout_weight="1"
/>
</TableRow>
<TableRow> <---THE BLACK BRODER AT THE BOTTOM OF THE LISTVIEW(not being displayed)
<TextView
android:background="#000000"
android:layout_width="0dip"
android:layout_height="0.5dp"
android:layout_weight="1" >
</TextView>
</TableRow>
</TableLayout>
See if this helps.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/orginalbild"
android:fillViewport="true"
android:gravity="center|top"
android:orientation="vertical"
android:stretchColumns="1"
android:weightSum="1.0" >
<TableRow android:background="#000000" >
<TextView
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_marginTop="0.15dp"
android:layout_weight="1"
android:background="#999999" >
</TextView>
</TableRow>
<TableRow android:background="#999999" >
<TextView
android:id="#+id/show_task_feedback_title"
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_marginBottom="0.15dp"
android:layout_weight="0.8"
android:background="#999999"
android:shadowColor="#FFFFFF"
android:text="#string/LatestFeedbackTitle"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:textSize="17dp" >
</TextView>
<TextView
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_gravity="center"
android:layout_weight="0.08" >
</TextView>
<Button
android:id="#+id/latest_feedback_help_button"
android:layout_width="0dip"
android:layout_height="28dp"
android:layout_gravity="center"
android:layout_marginBottom="0.15dp"
android:layout_weight="0.12"
android:background="#drawable/help_button" />
</TableRow>
<TableRow android:background="#212421" >
<TextView
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="0.15dp"
android:layout_weight="1"
android:background="#ffffff" >
</TextView>
</TableRow>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
</TableRow>
<TableRow
android:paddingTop="0.5dp"
android:paddingBottom="0.5dp"
android:background="#000000"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginBottom="20dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="#+id/bookmarks_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ffffff"
android:gravity="left"
android:entries="#array/listitems" />
</TableRow>
</TableLayout>

RelativeLayout over ListView, onclick not detected when RealtiveLayout is shown as

I am currently a relative layout is shown in a listview. Turns out that when I click RelativeLayout, is always caught the click event in the list view.
I wanted to detect a gesture on the layout when it is being shown, but when I click, the item is selected from the listview that is underneath.
Anyone know a solution to this problem?
<TabHost
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/start_tabs_topbar" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="0dp" >
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="0dp" />
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-4dp"
android:layout_weight="0" />
</LinearLayout>
</TabHost>
<RelativeLayout
android:id="#+id/playertab1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/back_artista"
android:gravity="center_vertical|left"
android:paddingLeft="15dp" >
<LinearLayout
android:id="#+id/music_info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity=""
android:orientation="horizontal" >
<ImageView
android:id="#+id/artist_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="9dp"
android:layout_marginTop="4dp"
android:src="#drawable/placeholder" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top"
android:orientation="vertical" >
<TextView
android:id="#+id/playlist_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="playlist_name"
android:textColor="#3BBEF9"
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="#+id/artist_album"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="artist_album"
android:textColor="#EEEEEE"
android:textSize="11dp" />
<TextView
android:id="#+id/artist_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="artist_album"
android:textColor="#EEEEEE"
android:textSize="11dp" />
<TextView
android:id="#+id/artist_song"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="artist_song"
android:textColor="#EEEEEE"
android:textSize="11dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
The listview as been inserted into:
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="0dp" />
If you are using GestureDetector try calling mDetector.setIsLongpressEnabled(true); first and set view long clickable via convertView.setLongClickable(true);

RelativeLayout with anchored top and bottom?

I'm trying to create an android screen that has a TableLayout anchored to the top, then a scrollview to fill middle, and TableLayout anchored to the bottom. I used a RelativeLayout with alignParentTop/alignParentBottom and the bottom TableLayout shows up, but the top one disappears.
Is it possible to have separate sections anchored at both top and bottom with a scrollable region filling the middle? Imagine a button bar on top and bottom with scrollable items in the middle. Here is my layout that was close but doesn't quite work. I also tried with a TableLayout and 3 rows with the middle one set to fill_parent and ScrollView, but couldn't get that to work either.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout01"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:id="#+id/CategoryTable01"
android:stretchColumns="*"
android:background="#000000"
android:layout_height="80px"
android:layout_alignParentTop="true"
android:layout_width="fill_parent">
<TableRow
android:id="#+id/tr01"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:padding="10px"
android:layout_gravity="center_vertical|center_horizontal">
<TextView android:text="TOP1" android:textColor="#0000FF" android:layout_height="fill_parent" android:layout_gravity="fill_vertical" android:textStyle="bold" />
<TextView android:text="TOP2" android:textColor="#CCCCCC" android:layout_height="fill_parent" android:layout_gravity="fill_vertical" android:textStyle="bold" />
</TableRow>
</TableLayout>
<ScrollView android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout02"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:id="#+id/TableLayout01"
android:stretchColumns="*"
android:background="#drawable/gradient"
android:layout_height="wrap_content"
android:paddingLeft="20px"
android:layout_width="fill_parent">
<TableRow
android:id="#+id/TableRow01"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical|center_horizontal">
<TextView android:textColor="#FFFFFF"
android:textStyle="bold"
android:textSize="12dip"
android:text="Sample Line 1"></TextView>
</TableRow>
<TableRow
android:id="#+id/TableRow02"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical|center_horizontal">
<TextView android:textColor="#FFFFFF"
android:textSize="11dip"
android:text="Sample Line 2"></TextView>
</TableRow>
<TableRow
android:id="#+id/TableRow03"
android:layout_height="600px"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical|center_horizontal">
<TextView android:textColor="#FFFF00"
android:textSize="11dip"
android:text="Sample Line 3"></TextView>
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
<TableLayout
android:id="#+id/CategoryTable02"
android:stretchColumns="*"
android:background="#000000"
android:layout_height="80px"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent">
<TableRow
android:id="#+id/tr02"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:padding="10px"
android:layout_gravity="center_vertical|center_horizontal">
<TextView android:text="ONE" android:textColor="#0000FF" android:layout_height="fill_parent" android:layout_gravity="fill_vertical" android:textStyle="bold" />
<TextView android:text="TWO" android:textColor="#CCCCCC" android:layout_height="fill_parent" android:layout_gravity="fill_vertical" android:textStyle="bold" />
<TextView android:text="THREE" android:textColor="#CCCCCC" android:layout_height="fill_parent" android:layout_gravity="fill_vertical" android:textStyle="bold" />
<TextView android:text="FOUR" android:textColor="#CCCCCC" android:layout_height="fill_parent" android:layout_gravity="fill_vertical" android:textStyle="bold" />
</TableRow>
</TableLayout>
</RelativeLayout>
Thanks for any suggestions or help.
Michael
It is indeed possible. This is how I've got it working in one of my apps (I've cut out a bunch of irrelevant stuff like ids):
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--this is the action bar at the top of the screen)-->
<fragment
android:layout_width="match_parent"
android:layout_height="40dip" />
<!-- This is the list view in the middle -->
<ListView
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dip">
</ListView>
<!-- This is a bunch of buttons at the bottom -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dip"
android:gravity="bottom">
</RelativeLayout>
</LinearLayout>
The key is to set your middle listview to height 0dip and let layout_weight take over - layout_weight is kind of comparable to percentage widths/heights in HTML - if you have 4 different elements with weight 0.25, they'll each take up a quarter of the screen. So weight 1.0 takes up whatever it can.

Categories

Resources