如何根据android中的材料设计制作Cardview?

新手上路,请多包涵

我看到了 Material design guidelines 关于但有点混乱,而我设计的卡片在左边有图像,在图像的右边有一些文字。但我不满意它是否符合指南……请检查并告诉。而且我还希望我的虚拟文本段落合理化。

这是我的代码:-

 <android.support.v7.widget.CardView
style="@style/MyCardViewStyle"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
>

<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_marginLeft="16dp"
        android:background="@drawable/video"
        android:scaleType="centerCrop"
        tools:ignore="ContentDescription"/>

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

    <TextView
        android:id="@+id/subHeaderText"
        style="@style/Base.TextAppearance.AppCompat.Subhead"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/headingText"
        android:layout_toRightOf="@+id/appImage"
        android:paddingLeft="16dp"
        android:text="SubTiltle"
        android:paddingRight="16dp"
        android:textColor="#000"
        android:textSize="15sp"/>

    <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:gravity="left"
        android:lines="5"
        android:maxLines="5"
        android:paddingBottom="16dp"
        android:paddingLeft="16dp"
        android:paddingTop="16dp"
        android:text="@string/stories_detail"
        android:textColor="#737078"
        android:textSize="14sp"/>

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

</RelativeLayout>

这是我的卡片视图:- 在此处输入图像描述

原文由 Rajesh 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 190
1 个回答

这是 GitHub 项目的 链接,其中 CardView 布局按照 Material Design 指南实施。

具有材料设计的 CardView

原文由 Eugene Brusov 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题