Android CardView卡片布局 标签: 控件
CardView介绍
CardView是Android 5.0系统引入的控件,相当于FragmentLayout布局控件然后添加圆角及阴影的效果;CardView被包装为一种布局,并且经常在ListView和RecyclerView的Item布局中,作为一种容器使用。CardView应该被使用在显示层次性的内容时;在显示列表或网格时更应该被选择,因为这些边缘可以使得用户更容易去区分这些内容。
使用
先看效果
首先在build.gradle文件添加依赖库
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
}
布局文件main.html文件下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"> <android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"> <ImageView
android:layout_width="150dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:scaleType="centerCrop"
android:src="@drawable/sng" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="棒冰行动"
android:textSize="18sp"
android:textStyle="bold" /> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="棒冰行动,公益传播设计夏令营" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView> </LinearLayout>
在MainActivity.Java下文件
public class MainActivity extends AppCompatActivity {
private CardView cardView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
cardView = (CardView)findViewById(R.id.cardView);
cardView.setRadius();//设置图片圆角的半径大小
cardView.setCardElevation();//设置阴影部分大小
cardView.setContentPadding(,,,);//设置图片距离阴影大小
}
}
Android CardView卡片布局 标签: 控件的更多相关文章
- Android控件进阶-自定义流式布局和热门标签控件
技术:Android+java 概述 在日常的app使用中,我们会在android 的app中看见 热门标签等自动换行的流式布局,今天,我们就来看看如何 自定义一个类似热门标签那样的流式布局吧,类 ...
- Android常用布局和控件
一.Android常用布局属性 1. LinearLayout的特有属性 android:orientation:设置布局排列方式 android:layout_weight:设置所占布局的权重 ...
- 让我们创建屏幕- Android UI布局和控件
下载LifeCycleTest.zip - 278.9 KB 下载ViewAndLayoutLessons_-_Base.zip - 1.2 MB 下载ViewAndLayoutLessons_-_C ...
- Android 标签控件
版本号:1.0 日期:2014.7.24 版权:© 2014 kince 转载注明出处 在有的应用中可能须要设置一些标签来方便用去去查询某些信息,比方手机助手或者购物软件之类都会有一些标签. ...
- Android开发工程师文集-相关控件的讲解,五大布局
前言 大家好,给大家带来Android开发工程师文集-相关控件的讲解,五大布局的概述,希望你们喜欢 TextView控件 TextView控件有哪些属性: android:id->控件的id a ...
- swing实现QQ登录界面1.0( 实现了同一张图片只加载一次)、(以及实现简单的布局面板添加背景图片控件的标签控件和添加一个关闭按钮控件)
swing实现QQ登录界面1.0( 实现了同一张图片只加载一次).(以及实现简单的布局面板添加背景图片控件的标签控件和添加一个关闭按钮控件) 代码思路分析: 1.(同一张图片仅仅需要加载一次就够了,下 ...
- Android 在程序中动态添加 View 布局或控件
有时我们需要在程序中动态添加布局或控件等,下面用程序来展示一下相应的方法: 1.addView 添加View到布局容器 2.removeView 在布局容器中删掉已有的View 3.LayoutPar ...
- Android自定义控件之自定义组合控件
前言: 前两篇介绍了自定义控件的基础原理Android自定义控件之基本原理(一).自定义属性Android自定义控件之自定义属性(二).今天重点介绍一下如何通过自定义组合控件来提高布局的复用,降低开发 ...
- android - 自定义(组合)控件 + 自定义控件外观
转载:http://www.cnblogs.com/bill-joy/archive/2012/04/26/2471831.html android - 自定义(组合)控件 + 自定义控件外观 A ...
随机推荐
- 紫书 习题 8-15 UVa 1617 (贪心)
先排序, 然后每个线段先放右端点, 然后往下放, 如果不能放就整体往左移动, 当不能往左移动的时候就ans++ 开始下一个整块.判断能不能向左移动要用一个变量储存每个已经放了的区间中线段与左端点距离的 ...
- LeetCode——Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 写一个函数找出字符串数组中 ...
- iOS_青花瓷Charles抓包
使用青花瓷Charles抓取手机端的网络请求: 第一步,下载安装并打开Charles watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcHJlX2VtaW5l ...
- Cannot find the class file for javax.servlet.ServletContext.
当eclipse中新导入的Java Project的时候.往往会碰到各种各样的问题,以下是个典型的问题: Cannot find the class file for javax.servlet.Se ...
- jquery去重
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title> ...
- 智课雅思词汇---八、ject是什么意思
智课雅思词汇---八.ject是什么意思 一.总结 一句话总结:词根:ject, jac(jet) = to throw(投掷, 扔) 1.geo是什么意思? 词根:-ge-, -geo- [词根含义 ...
- zzulioj--1778-- 和尚特烦恼4——有多少战斗力(gcd)
1778: 和尚特烦恼4--有多少战斗力 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 259 Solved: 123 SubmitStatusWe ...
- django 笔记17 ModelForm
Model 数据库操作 验证 验证 Form -class LoginForm(Form): email = fields.EmailField() is_valid 每一个字段进行正则(字段内置正则 ...
- 使用Chrome浏览器,让我们远离(所有)广告
你是否还在为浏览网页时各种广告霸屏而急躁不安?这里分享一个小技巧,如何自动屏蔽各大广告. 这里使用的浏览器是Chrome,直接在Chrome网上应用商店搜索下载安装AdBlock插件(不知道其它浏览器 ...
- strlen() 和 sizeof() 的区别
1.strlen() 时函数,他在程序运行时才能计算.它的参数类型要求时 char *,且必须是以'/0'结尾.数组在传入时已经退化为指针.它的作用是返回数组中字符串的长度. 2.sizeof()时运 ...