hunterp
hunterp

Reputation: 15976

Why is my button hidden?

The button is hidden...why?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="15dp"
    android:orientation="vertical">
    <ListView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/feed_list"/>
    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="More"
        android:id="@+id/feed_more"/>
</LinearLayout>

Upvotes: 0

Views: 322

Answers (2)

Debarati
Debarati

Reputation: 3286

you need to give weight 1 to the list view. then your button will be visible. try it.

Upvotes: 1

Cheryl Simon
Cheryl Simon

Reputation: 46844

Assuming that the ListView has enough content to fill up the whole screen, it will since you told it to wrap_content. You can use weights to instruct the ListView to take up as much of the screen as is available, after the button has what it needs:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="15dp"
android:orientation="vertical">
<ListView
    android:layout_width="fill_parent"
    android:layout_height="0"
    android:weight="1"
    android:id="@+id/feed_list"/>
<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:weight="0"
    android:text="More"
    android:id="@+id/feed_more"/>

Upvotes: 6

Related Questions