Reputation: 43
I want to show LinearLayout after complete ListView is displayed. My code shows ListView and fixed LinearLayout at bottom. I don’t want LinearLayout fixed at bottom.
What I want is: if my ListView has 20 items, user scroll to view all items and see LinearLayout at the end of ListView items.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="75dp"
android:footerDividersEnabled="false" />
<LinearLayout
android:id="@+id/ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/border"
android:orientation="vertical"
android:paddingBottom="10dip"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="10dip" >
<TextView
android:id="@+id/Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingBottom="10dip"
android:paddingLeft="5dip"
android:textSize="14dip"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dip"
android:paddingTop="10dip"
android:text="Your Email:"
android:textSize="12dip" />
<EditText
android:id="@+id/newEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingBottom="5dip" />
<Button
android:id="@+id/buttonNew"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
</RelativeLayout>
Upvotes: 0
Views: 433
Reputation: 1264
Add a footer view to your listView, So your layout look like this.
main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:footerDividersEnabled="false" />
</RelativeLayout>
footer.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:orientation="vertical"
android:paddingBottom="10dip"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="10dip" >
<TextView
android:id="@+id/Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingBottom="10dip"
android:paddingLeft="5dip"
android:textSize="14dip"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dip"
android:paddingTop="10dip"
android:text="Your Email:"
android:textSize="12dip" />
<EditText
android:id="@+id/newEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingBottom="5dip" />
<Button
android:id="@+id/buttonNew"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
code:
View footerView = ((LayoutInflater) ActivityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer ayout, null, false);
ListView.addFooterView(footerView);
Thats it.
Upvotes: 0
Reputation:
You should use a ListView footer.
View footerView = ((LayoutInflater) ActivityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
ListView.addFooterView(footerView);
Your footer_layout
could be whatever you want, for example a LinearLayout
. You have to do this AFTER you set the Adapter
.
Upvotes: 2
Reputation: 100468
Use addFooterView(View)
for this.
Add a fixed view to appear at the bottom of the list. If addFooterView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.
Parameters
- v The view to add.
Upvotes: 2