android recyclerview gridview项目显示不正确
问题描述:
我正在使用recyclerview gridview显示产品。但它的表现是这样 this is the viewandroid recyclerview gridview项目显示不正确
我的XML视图代码是
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/tools"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="@dimen/cover_height"
android:layout_height="wrap_content"
android:layout_gravity="center"
card_view:cardUseCompatPadding="true"
android:elevation="7dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.makeramen.roundedimageview.RoundedImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/thumbnail"
android:src="@drawable/placeholder_image"
android:scaleType="fitXY"
app:riv_oval="false"
app:riv_corner_radius_top_left="6dp"
app:riv_corner_radius_top_right="6dp"
android:layout_height="@dimen/cover_height"
android:layout_width="match_parent" />
<pseudozero.smalam.com.finwallet.utils.TextViewPlus
android:id="@+id/tvProductTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/thumbnail"
android:textColor="@color/colorBlack"
android:textSize="15dp"
android:text="Wrist Watch"
android:padding="5dp"
app:customFont="fonts/Proxima_Nova_Bold.otf"/>
<pseudozero.smalam.com.finwallet.utils.TextViewPlus
android:id="@+id/tvProductVendor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tvProductTitle"
android:textSize="13dp"
android:paddingLeft="5dp"
android:paddingBottom="5dp"
android:text="Rolex"
app:customFont="fonts/Proxima_Nova_Reguler.otf"/>
<pseudozero.smalam.com.finwallet.utils.TextViewPlus
android:id="@+id/tvPriceTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="500 BDT"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:textColor="@color/colorWhite"
android:textSize="13dp"
android:padding="10dp"
android:background="@drawable/price_tag_back_n"
app:customFont="fonts/Proxima_Nova_Bold.otf"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
我使用里面的LinearLayout卡片视图。但我得到这个 我正在从服务器加载所有数据。只有第二个项目正在上升。我希望所有的物品都会被装饰。
答
- 使用固定
CardView
和RoundedImageView
- 使用属性
android:scaleType="centerCrop"
代替android:scaleType="fitXY"
的高度RoundedImageView
。
希望这将有助于〜
+0
它:( –
答
RelativeLayout的高度应WRAP_CONTENT
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
到
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
而在你的代码,你不要靠近父母的LinearLayout。
你需要修复形象的高度布局 –
我修正了自己的卡片视图 –
一套固定高度的高度,我有固定cardview的高度,但其表示不工作一样:( –