views:

50

answers:

1

I have a layout that is three linear layouts. The top has some icons and the middle has a tabhost. Each tabhost has a list inside it. The bottom linearlayout has two buttons that should stay at the bottom on the screen at all times. The problem is when a list in the tabhost gets too long, it displays over the buttons. I tried to find some way to get the buttons to bedisplayed over the list but have failed so far. Any help would be appreciated. :-) Thanks!

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TabHost 
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content">
        <LinearLayout 
            android:orientation="vertical"
            android:layout_width="fill_parent" 
            android:layout_height="395dp"
            android:background="#000000">
            <TabWidget 
                android:id="@android:id/tabs"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" 
            />
            <FrameLayout 
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:padding="5dp" 
            />
        </LinearLayout>
    </TabHost>
</LinearLayout>

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" 
android:layout_width="fill_parent"
android:layout_height="fill_parent" 
android:gravity="fill"
android:layout_margin="0dp" 
android:padding="0dp" 
>
<Button 
    android:id="@+id/btnGroup" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:text="Ptt" 
    android:layout_gravity="bottom" 
    android:layout_weight="2"
    android:hapticFeedbackEnabled="true"/>
<Button 
    android:id="@+id/btnMenu" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:text="Menu" 
    android:layout_gravity="bottom"
    android:layout_weight="2" 
    android:hapticFeedbackEnabled="true"/>
</LinearLayout>
A: 

I generally put my LinearLayouts inside of a ScrollView to solve this situation. (The buttons stay outside) It allows your buttons to stay in the correct location at all times and the user scroll the rest of the view.

ScrollView Docs

smith324
Thank you for your answer. I do have the buttons at the bottom at all times now! However, I am feeling rather stupid as now the scroll view is not big enough and leaves lots of empty space before the buttons. I tried setting minHeight and also trying fillViewPort but niether seems to be working. ANy ideas?
Mlove
Nevermind I made a silyl mistake. I thought you could only do "fill_parent" or "wrap_content" for height but have realized I can put numbers in there. Thanks for your help Chris! :-)
Mlove
Instead of using the numbers I would set the weight of the scroll view to 2 so that it will occupy any unfilled space. Setting numbers is bad practice when dealing with multiple screen sizes in most cases.
smith324
I gave that a shot because I dont like using numbers either. However when I set weight it still does fill the rest of the screen.<ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="2">
Mlove
Sorry I meant to say does not
Mlove
Please edit your question and add the new layout in a code block please.
smith324