2015-07-14 3 views
0

Вот результат я получаю: - http://i.stack.imgur.com/10UbN.png (я не имею достаточно кредитов на публикацию изображения)Android Full Width CardView

Вот это 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> 

Я хочу чтобы получить полный вид карты, который я не могу достичь. Помощь! Спасибо :)

+0

вы можете показать вам Ресайклер XML или XML активности, где вы установили свой вид карты. может быть прокладка .. well cardview: cardUseCompatPadding do Добавить дополнение в API v21 +, чтобы иметь те же измерения с предыдущими версиями. – abhishek

ответ

0

Попробуйте это:

<?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> 
+0

Nope не работает – user5114191

+0

http://i.imgur.com/hFeXOGh.png – user5114191

+0

Вы уверены, что задали ширину 'match_parent'? и показать корневой макет. –

0

Что в вашей onCreateViewHolder?
Попробуйте надувать вашу карту таким образом

final View itemView = LayoutInflater. 
      from(parent.getContext()). 
      inflate(R.layout.item_preview, parent, false);