Reputation: 2771
I found few topics here on SO, but they are not what i'm searching. One of them is this one Android ListActivity - how to add a view below the ListView?
I know i can position a View (like button) at the footer of listview. That means desired View will position itself AFTER last view.
I want to know how to position a View at the end of the screen (Just below). Please check two pictures below:
I want to do this in java code. Any ideas?
Upvotes: 2
Views: 1307
Reputation: 133560
Use a Relative Layout. Set the Height of Listview to the required height. Place the button relative to the listview at the button.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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" >
<ListView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="TextView" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="122dp"
android:text="Button" />
</RelativeLayout>
Upvotes: 1
Reputation: 2261
try the following code
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
>
</ListView>
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Button" />
Upvotes: 1