Making a static button in the bottom of the screen with list view
Hey, I'm trying to create a layout to my activity but I can't make a static button at the bottom of the screen, that won't hide the list view last items. I saw a lot of ways but all of them are hiding my list view's last items. I thought about using "weight" parameter, but it's not looking so good. The activity I'm trying to make has an image view in her top, below the image view comes the list, which is not static, and down the bottom suppose to be a static button, that won't be over list view. This is the xml I wrote, but as you can see, if you will try to "run" it (just add some stuff inside the table layout), that if the list is long is being hidden under the button. PS: I'm working on building the list view so for now it's a table layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:background="@drawable/background">
<ImageView android:src="@drawable/search_title"
android:layout_alignParentTop="true" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:paddingTop="10dip"
android:layout_gravity="center" android:id="@+id/shop_list_title" />
<ScrollView android:layout_marginBottom="1dip"
开发者_C百科 android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_below="@id/shop_list_title">
<TableLayout android:id="@+id/shop_list_list"
android:layout_width="fill_parent" android:layout_height="wrap_content">
</TableLayout>
</ScrollView>
<Button android:id="@+id/shop_list_search_button" android:layout_alignParentBottom="true"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:text="@string/search_button_shoplist" />
</RelativeLayout>
Thanks in advance, Elad!
I would recommend using LinearLayout
in your case.
Here is an example. I removed all noisy stuff and left only relevant attributes:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent" >
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TableLayout>
</ScrollView>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
精彩评论