2016-05-13 6 views
0

私は、card viewimageとを含有する活性がlistviewであり、textである。アンドロイドの素材デザインに合わせてカードサイズを作る方法は?

素材デザインに合わせてカードビューのディメンションを作りたいです。どうやってやるの?材料設計に基づいてコードを変更する必要があることを誰かが助けてくれて、親切に指摘できましたか?ここで

は、これまでの私のコードです:

<android.support.v7.widget.CardView android:id="@+id/card_view" 
           xmlns:android="http://schemas.android.com/apk/res/android" 
           xmlns:card_view="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:layout_margin="5dp" 
           android:background="#424767" 
           android:foreground="?attr/selectableItemBackground" 
           android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
           card_view:cardCornerRadius="@dimen/card_corner_radius" 
           card_view:cardElevation="@dimen/card_elevation"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <ImageView 
      android:id="@+id/appImage" 
      android:layout_width="72dp" 
      android:layout_height="72dp" 
      android:layout_above="@+id/subHeadingText" 
      android:layout_marginTop="10dp" 
      android:scaleType="centerCrop" 
      tools:ignore="ContentDescription"/> 

     <TextView 
      android:id="@+id/headingText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="5dp" 
      android:layout_toRightOf="@+id/appImage" 
      android:paddingLeft="16sp" 
      android:paddingRight="16dp" 
      android:paddingTop="24sp" 
      android:text="Hello" 
      android:textColor="#000" 
      android:textSize="24sp" 
      tools:ignore="RtlHardcoded"/> 

     <TextView 
      android:id="@+id/subHeaderText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/headingText" 
      android:layout_toRightOf="@+id/appImage" 
      android:paddingBottom="16dp" 
      android:paddingLeft="16dp" 
      android:paddingRight="16dp" 
      android:text="14sp" 
      android:textColor="#000"/> 

     <TextView 
      android:id="@+id/subHeadingText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/subHeaderText" 
      android:layout_toRightOf="@+id/appImage" 
      android:lines="4" 
      android:paddingLeft="16dp" 
      android:paddingRight="16dp" 
      android:text="@string/stories_detail" 
      android:textColor="#737078" 
      android:textSize="14sp"/> 


    </RelativeLayout> 

    <Button 
     android:id="@+id/getDealBtn" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="10dp" 
     android:background="@drawable/get_deal_button" 
     android:elevation="2dp" 
     android:textAllCaps="true" 
     android:textColor="#FFFF" 
     android:textSize="14dp" 
     android:textStyle="bold"/> 
</LinearLayout> 

And here is my Image for this.

は、事前にありがとうございます。

答えて

0

このようなものを使用し、それに応じて設計する必要があります。影響を与える

enter image description here

<android.support.v7.widget.CardView 
    android:id="@+id/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" 
    android:layout_margin="2dp" 
    card_view:cardBackgroundColor="#fff" 
    card_view:cardCornerRadius="3dp" 
    card_view:cardElevation="2dp" 
    card_view:cardUseCompatPadding="true" 
    > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     > 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center_horizontal" 
      android:text="Check in"/> 

     <TextView 
      android:id="@+id/txtCheckInTime" 
      style="@style/Base.TextAppearance.AppCompat.Subhead" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center_horizontal" 
      android:text="9:20AM"/> 

     <View 

      android:id="@+id/viewStatus" 
      android:layout_width="match_parent" 
      android:layout_height="10dp" 
      android:background="@color/clrPresent" 
      /> 


    </LinearLayout> 
</android.support.v7.widget.CardView> 
+0

、それはあなたのために便利です見に実行します。カードレイアウトのプロパティを適切に設定するだけです。 –

関連する問題