当前位置:首页 » 安卓系统 » android卡片效果图

android卡片效果图

发布时间: 2025-10-15 02:26:18

1. android 安卓 类似ONE卡片页(包含图片文字等)怎么实现

Android5.0中向我们介绍了一个全新的控件–CardView,从本质上看,可以将CardView看做是FrameLayout在自身之上添加了圆角和阴影效果。请注意:CardView被包装为一种布局,并且经常在ListView和RecyclerView的Item布局中,作为一种容器使用。

下面例子来源于android学习手册, android学习手册包含9个章节,108个例子,源码文档随便看,例子都是可交互,可运行,源码采用android studio目录结构,高亮显示代码,文档都采用文档结构图显示,可以快速定位。360手机助手中下载,排在第四个。

CardView应该被使用在显示层次性的内容时;在显示列表或网格时更应该被选择,因为这些边缘可以使得用户更容易去区分这些内容。

使用CardView

首先,假设你的布局如同下面的形式:

<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <!-- Main Content View --> <RelativeLayout> ... </RelativeLayout> </FrameLayout>

为了使用上面的布局方式来创建一个卡片,首先你需要导入支持的依赖库(android-support-v7-cardview的jar包)在你的build.gradle文件中。

dependencies { ... compile 'com.android.support:cardview-v7:21.0.2' }

现在将FrameLayout替换为CardView,

<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <!-- Main Content View --> <RelativeLayout> ... </RelativeLayout> </android.support.v7.widget.CardView>

就是这样!使用依赖库能够保证你的程序稳定的兼容之前的版本;尽管在AndroidL和之前的Android版本中对其处理方式有所不同。

热点内容
c语言自学视频教程 发布:2025-10-15 06:09:52 浏览:446
oracle数据库脚本导出 发布:2025-10-15 06:03:18 浏览:552
qt编译pro 发布:2025-10-15 06:03:17 浏览:761
儿童编程都在学什么 发布:2025-10-15 05:45:21 浏览:820
python字符整型 发布:2025-10-15 05:43:54 浏览:275
平板访问谷歌 发布:2025-10-15 05:42:28 浏览:159
mysql整个数据库备份 发布:2025-10-15 05:36:52 浏览:210
DO2算法 发布:2025-10-15 05:30:36 浏览:691
android主线程ui 发布:2025-10-15 05:30:25 浏览:415
废汽油存储 发布:2025-10-15 05:23:37 浏览:874