I have a layout that looks like the following like below.
My problems is that on small screens, the button at the bottom of the view gets pushed of out view for the user. I thought i could easily remedy this by wraping the whole layout in a ScrollView, but I´ve since learned that this is not a feasible solution since there is a ListView in my layout.
So, any suggestions on how to change this layout? My main issue is really that I have an adapter connected to the ListView, and I´m not sure if I can redo the layout and use the adapter. Thoughts anyone?
Regards
Daniel
BTW, here´s my layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
style="@style/defaultBackground"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:paddingBottom="10dip"
>
<TextView
android:id="@+id/roundInfo"
android:layout_width="wrap_content"
android:layout_height="20dip" android:textColor="#000"
/>
<TextView
android:id="@+id/balance"
android:layout_width="fill_parent"
android:layout_height="20dip"
android:gravity="right"
android:textColor="#000"
/>
</LinearLayout>
<ListView
android:id="@android:id/list"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:textSize="10sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:listSelector="@drawable/custom_row"
android:background="@drawable/custom_listview"
android:dividerHeight="0dip"
android:cacheColorHint="#FFFFFF"
android:fadingEdge="none"
android:divider="#FFFFFF"
/>
<TextView
android:id="@+id/gameCost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/gameCost_not_finished"
android:textColor="#000" \
android:paddingTop="10dip"
/>
<Button
android:id="@+id/update_button"
android:text="@string/placebet_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/whiteText"
android:background="@drawable/custom_button"
/>
</LinearLayout>
For this type of situation, you should use a RelativeLayout instead of a LinearLayout. Try something like this:
Basically, change your root layout to a RelativeLayout, and separate your content into three areas: header, body, footer. Keep your header as is, inside the horizontal LinearLayout, and set it to alignParentTop. Since it’s only set to wrap_content, we don’t have to worry about weights or anything. Then, place the other fixed items that should be on bottom (the gameCost text and the placeBet button) into a vertical LinearLayout that serves as a footer. Set it to alignParentBottom. Finally, declare your ListView with a height of fill_parent. This will take the remaining space, but to keep it within the bounds of your header and footer, we add the layout_above and layout_below parameters. Hope this helps!