2016-05-06 4 views
0

私はカードビューで画像を表示するためにこのレイアウトを持っています。カードビューでスクロールして、アンドロイド素材デザインのギャップを作る

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" android:layout_height="match_parent" 
    android:padding="16dp" 
    > 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/cv" 
     > 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="16dp" 
      > 

      <ImageView 
       android:id="@+id/thumbnail" 
       android:layout_width="100dip" 
       android:layout_height="100dip" 
       android:adjustViewBounds="true" 
       android:scaleType="fitXY" /> 

     </RelativeLayout> 

    </android.support.v7.widget.CardView> 

</LinearLayout> 

画面が読み込まれるとすべてが完璧に見えます。しかし、画面上をスクロールすると、2つのグリッドの間に垂直方向のギャップができます。ギャップの大きさは画面の高さに等しい。結果として、スクロール後に画面上に2グリッドしか表示されません。

この現象はなぜですか?これを修正する方法は?

+1

こちらを参考にしてください。 http://stackoverflow.com/questions/36782333/gap-between-cardviews-increases-on-scrolling –

+0

どのようにスクロールしているのか教えていただけますか?それはLIstまたはリサイクルビューか一部のScrollViewですか? –

答えて

0
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" android:layout_height="match_parent" 
    android:padding="16dp" 
    > 

ところで、ルートビューのpfアイテムには、高さmatch_parentを使用しないでください。それはwrapContentか、ImageViewHeightが100dpであることがわかります。ここに16dpのパディングを追加すると、

高さを132 dpとして使用します。

関連する問題