CardView是Android 5.0之后发布的卡片效果控件,包:android.support.v7.widget.CardView
效果:可以实现圆角效果、阴影效果、让你的ui更立体。
列表适配器布局文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<ImageView
android:layout_width="120dp"
android:layout_height="70dp"
android:background="@drawable/ic_xuanfeng"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:gravity="center_vertical"
android:textSize="13sp"
android:maxLines="4"
android:ellipsize="end"
android:text="我奔跑在我孤傲的路上,使然看不见终点和希望,有太多火焰冷却我的理想,我依然燃烧我仍在信仰。"/>
</LinearLayout>
</android.support.v7.widget.CardView>
本文介绍了如何利用Android 5.0之后发布的CardView控件来实现卡片效果,包括圆角和阴影等特性,以此增强用户界面的立体感。通过一个具体的布局文件示例展示了CardView的基本用法。
686

被折叠的 条评论
为什么被折叠?



