2012-08-16 73 views
1

我有一个“grid_test.xml”的GridView没有填满屏幕

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/linearLayoutGrid" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 

<GridView 
android:id="@+id/gridView" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:columnWidth="90dp" 
android:gravity="center" 
android:horizontalSpacing="5dp" 
android:numColumns="auto_fit" 
android:stretchMode="columnWidth" 
android:verticalSpacing="5dp" > 
</GridView> 
</LinearLayout> 

我包括这在页眉和页脚另一个布局:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:id="@+id/commonlayout" > 


<LinearLayout android:id="@+id/llheader" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:background="@android:color/white"> 

    <RelativeLayout android:id="@+id/relativeLayout1" 
     android:layout_width="fill_parent" android:layout_height="fill_parent" 
     android:layout_gravity="center"> 
     <Button 
      android:id="@+id/Button_Logo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_marginRight="2dp" 
      android:layout_centerVertical="true" 
      android:background="@drawable/ic_launcher"/> 
      <Button 
      android:id="@+id/Button_settings" 
      android:layout_marginLeft="2dp" 
      android:layout_width="wrap_content" 
      android:layout_centerVertical="true" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:background="@drawable/ic_launcher"/> 
    </RelativeLayout> 
</LinearLayout> 


<ScrollView android:id="@+id/svdata" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#FFFFFF" 
    android:layout_below="@+id/llheader" 
    android:layout_above="@+id/llfooter" > 

    <LinearLayout 
     android:id="@+id/lldata" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@color/backgound_color" 
     android:orientation="vertical" 
     android:padding="5dp" > 

     <include layout="@layout/grid_test" /> 

    </LinearLayout> 

</ScrollView> 

<LinearLayout android:id="@+id/llfooter" 
    android:layout_width="fill_parent" 
    android:orientation="horizontal" 
    android:layout_height="wrap_content" 
    android:visibility="visible" 
    android:layout_margin="0dp" 
    android:layout_alignParentBottom="true" 
    > 

    <RadioGroup 
     android:id="@+id/radiogroup" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/black" 
     android:orientation="horizontal" > 
     <RadioButton 
      android:id="@+id/btnOption1" 
      style="@style/navbar_button" 
      android:drawableTop="@drawable/ic_launcher" 
      android:singleLine="true"/> 

     <RadioButton 
      android:id="@+id/btnOption2" 
      style="@style/navbar_button" 
      android:drawableTop="@drawable/ic_launcher" 
      android:singleLine="true"/> 

     <RadioButton 
      android:id="@+id/btnOption3" 
      style="@style/navbar_button" 
      android:drawableTop="@drawable/ic_launcher"/> 

    </RadioGroup> 
</LinearLayout> 
</RelativeLayout> 

我的问题是,包括GridView控件布局不会填充页眉和页脚之间的屏幕。

什么可能导致问题?

回答

1

好的。我找到了。删除ScrollView,使其按预期工作。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:id="@+id/commonlayout" > 


<LinearLayout android:id="@+id/llheader" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:background="@android:color/white"> 

    <RelativeLayout android:id="@+id/relativeLayout1" 
     android:layout_width="fill_parent" android:layout_height="fill_parent" 
     android:layout_gravity="center"> 
     <Button 
      android:id="@+id/Button_Logo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_marginRight="2dp" 
      android:layout_centerVertical="true" 
      android:background="@drawable/ic_launcher"/> 
      <Button 
      android:id="@+id/Button_settings" 
      android:layout_marginLeft="2dp" 
      android:layout_width="wrap_content" 
      android:layout_centerVertical="true" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:background="@drawable/ic_launcher"/> 
</RelativeLayout> 
</LinearLayout> 

    <LinearLayout 
     android:id="@+id/lldata" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@color/backgound_color" 
     android:orientation="vertical" 
     android:layout_below="@+id/llheader" 
     android:layout_above="@+id/llfooter" 
     android:padding="5dp" > 

     <include layout="@layout/grid_test" /> 

    </LinearLayout> 

<LinearLayout android:id="@+id/llfooter" 
    android:layout_width="fill_parent" 
    android:orientation="horizontal" 
    android:layout_height="wrap_content" 
    android:visibility="visible" 
    android:layout_margin="0dp" 
    android:layout_alignParentBottom="true" 
    > 

    <RadioGroup 
     android:id="@+id/radiogroup" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/black" 
     android:orientation="horizontal" > 
     <RadioButton 
      android:id="@+id/btnOption1" 
      style="@style/navbar_button" 
      android:drawableTop="@drawable/ic_launcher" 
      android:singleLine="true"/> 

     <RadioButton 
      android:id="@+id/btnOption2" 
      style="@style/navbar_button" 
      android:drawableTop="@drawable/ic_launcher" 
      android:singleLine="true"/> 

     <RadioButton 
      android:id="@+id/btnOption3" 
      style="@style/navbar_button" 
      android:drawableTop="@drawable/ic_launcher"/> 

    </RadioGroup> 
</LinearLayout> 
</RelativeLayout>