为什么GridView会不断调整自身大小?

时间:2014-03-26 22:15:10

标签: java android android-listview android-gridview

我正在尝试在我的Android应用程序中实现GridView,但似乎GridView不断调整大小。我已附上以下视频(请注意滚动条)。虽然它很微妙,但它真的很烦人,并且阻碍了我试图实现的视差滚动。

视频:GridView Issue

网格项布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="120dp"
     android:orientation="vertical"
     android:background="@drawable/card_background"
     >

    <TextView 
         android:id = "@+id/foo"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginLeft="10dp"
         android:layout_marginTop="10dp"
         android:layout_marginRight="10dp"  
         android:layout_marginBottom="40dp"      
         style="@style/PrimaryBlueHeading"
     />

    <View
        android:id="@+id/list_uinderline"
        android:layout_marginTop="10dp"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="@android:color/white"/>



    <Button
        android:id="@+id/bar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:focusable="false"

        android:background="@color/brand_color"
        android:paddingTop="2dp"
        android:paddingBottom="2dp"
        android:text="@string/save"
        android:textColor="@android:color/white" />


</LinearLayout>

GridView布局:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ProtocolListActivity">
     <!-- android:paddingTop="?android:attr/actionBarSize" --> 


    <GridView
        android:id="@+id/protocol_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:clipToPadding="false"
        android:columnWidth="200dp"
        android:numColumns="auto_fit"
        android:verticalSpacing="50dp"
        android:background="@drawable/backgound_potrait"
        android:horizontalSpacing="50dp"
        android:stretchMode="columnWidth"
        android:scrollbarStyle="outsideOverlay"
        android:gravity="center">
    </GridView>

</RelativeLayout>

0 个答案:

没有答案