リストからいくつかのCardViewを表示するRecyclerViewを実装しましたが、問題が表示されたときにカード間に余裕があり、スペースはCardViewと同じスペースです高さが高く、各カードの底部にのみあります。カード間のRecyclerView、CardView、 "dead"スペース
これは私のコードです:
CardView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:padding="5dp">
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="245dp"
android:layout_gravity="center_horizontal"
cardview:cardElevation="4dp"
cardview:cardCornerRadius="5dp"
android:layout_marginBottom="0dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="240dp"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="fill_parent"
android:layout_height="100dp"
android:id="@+id/ivProduct"
android:scaleType="centerCrop" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#333333"
android:text="Photo Title"
android:id="@+id/txtTipo"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="5dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#333333"
android:text="Photo Title"
android:id="@+id/txtdescripcion"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="5dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
RecyclerView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
[2]
[[2] [2]!]
何が起きているのかを示す画像を追加します。おそらく、あなたは 'android:layout_height'と比べて十分な高さを使用していない可能性が高いので、2つの間に奇妙な間隔があります。あなたは代わりにコンテンツをラップすることができます。 –
イメージを置くだけで、どこにコンテンツをラップする必要がありますか? – elunap
あなたは 'RecyclerView'で親全体を塗りつぶしているので、フルスクリーンに1つのアイテムしか表示されないように見えます。代わりに 'wrap_content'を使うべきです。実際の「RecyclerView」ではこれが変わるはずだと思う。あなたのカードのあなたの親のレイアウトでは、代わりに 'match_parent'を使うべきです。 –