收录日期:2019/06/20 13:35:10 时间:2010-06-22 20:40:56 标签:android,gridview,layout,button

I've got the following layout XML file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_layout" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<GridView android:id="@+id/main_grid_screen"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:numColumns="auto_fit" android:verticalSpacing="30dp"
    android:horizontalSpacing="10dp" android:columnWidth="90dp"
    android:stretchMode="columnWidth" android:gravity="center" />
<Button android:id="@+id/clickable_area" android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
android:text="@string/view_items_area" />
</LinearLayout>

The GridView shows up perfectly fine; however, the Button below it is completely absent. If I place the Button tag above the GridView, it appears. What gives?

I think it is because of the fill_parent attributes. The GridView is most likely taking up the entire screen and blocking your view of the button. You could try wrap_content instead.