Issue
I want to add a button at the end of a list view. I have the following xml file. The list view appears with its contents, but the button does not show up.
<?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"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myListView" />
<Button
android:text="Project Download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/download" />
</LinearLayout>
Solution
The problem is with the attribute android:layout_height="match_parent"
in your ListView. match_parent
means that the listview will fill all the space. The correct way is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:weight="1"
android:id="@+id/myListView" />
<Button
android:text="Project Download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/download" />
</LinearLayout>
Answered By - heloisasim
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.