[英]Android Full Width CardView
這是我得到的輸出: -http : //i.stack.imgur.com/10UbN.png (我沒有足夠的積分來發布圖像)
這是我正在使用的XML代碼:-
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/myCardView"
cardview:cardUseCompatPadding="true"
cardview:cardCornerRadius="2dp"
cardview:cardElevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:id="@+id/relLayout"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/thumbnail"
android:layout_width="100dp"
android:layout_height="80dp"
android:scaleType="centerCrop"
android:src="@drawable/placeholder"
android:contentDescription="Event Image"
android:layout_weight="1"
/>
<LinearLayout
android:layout_weight="20"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="3"
android:padding="8dp"
android:text="Event Title"
android:textColor="#222"
android:textSize="20sp"
android:layout_gravity="top|left"
android:gravity="top"
tools:ignore="RtlHardcoded"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Short Description of Event"
android:textColor="#222"
tools:ignore="RtlHardcoded"
android:maxLines="3"
android:id="@+id/short_desc"
android:padding="8dp"/>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1000"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
我想獲得我無法實現的全寬度卡片視圖。 救命 ! 謝謝 :)
嘗試這個:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
....
</LinearLayout>
</android.support.v7.widget.CardView>
您的onCreateViewHolder
什么?
嘗試以這種方式充值卡
final View itemView = LayoutInflater.
from(parent.getContext()).
inflate(R.layout.item_preview, parent, false);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.