Android layer-list的属性和使用具体解释。layer-list是用来多个图层堆叠显示的,借这个特性能够做一些特别的效果(比方:阴影、以下的效果等),也能够投机取巧。

1.代码片

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <!--近期的项目中须要用到多个图层堆叠到一块儿,就研
究了一下android中的layer-list。android中的layer-list
就是用来多个图层堆叠显示的。 -->
<item>
<shape > <!-- 第一层的颜色为蓝色 -->
<solid android:color="@color/blue"/>
</shape>
</item> <!-- 第二层的颜色。也就是最上面的一层,由于第二层相对于
View的底部上移两个dp所以第一层会露出一个dp的黑色所以
给人一种仅仅有底部边框的假象 -->
<item android:bottom="2dip">
<shape>
<solid android:color="@color/white"/>
</shape>
</item> </layer-list>

2.布局代码和效果图 (一定要注意在使用RadioGroup的时候要记的写RadioButton的id,否则不能切换)

    	<RadioGroup
android:id="@+id/rg"
android:layout_below="@id/bt2"
android:layout_margin="10dip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <RadioButton
android:id="@+id/rb0"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:button="@null"
android:text="分类"
android:checked="true"
android:gravity="center"
android:textColor="@color/black"
android:background="@drawable/ch_bg"
android:layout_marginTop="2dip"
android:paddingBottom="4dip"/> <RadioButton
android:id="@+id/rb1"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:text="分类"
android:button="@null"
android:gravity="center"
android:textColor="@color/black"
android:background="@drawable/ch_bg"
android:layout_marginTop="2dip"
android:paddingBottom="4dip"/> </RadioGroup>

选择器

<?

xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true" android:drawable="@drawable/bg_li"></item>
<item android:state_checked="false" android:drawable="@color/white"></item>
</selector>

效果图

3.代码片

<?xml version="1.0dip" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item>
<bitmap android:src="@drawable/ic_launcher"
android:gravity="center"/>
</item>
<item android:left="10dip" android:top="10dip">
<bitmap android:src="@drawable/ic_launcher"
android:gravity="center"/>
</item>
<item android:left="20dip" android:top="20dip">
<bitmap android:src="@drawable/ic_launcher"
android:gravity="center"/>
</item>
<item android:left="30dip" android:top="30dip">
<bitmap android:src="@drawable/ic_launcher"
android:gravity="center"/>
</item> </layer-list>

效果图

4.代码片

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/ic_launcher"></item>
<item android:left="10dip" android:top="10dip" android:drawable="@drawable/ic_launcher"></item>
<item android:left="20dip" android:top="20dip" android:drawable="@drawable/ic_launcher"></item>
<item android:left="30dip" android:top="30dip" android:drawable="@drawable/ic_launcher"></item> </layer-list>

5.知识库连接:

http://blog.csdn.net/brokge/article/details/9713041

http://www.aitinan.com/4004.html

http://www.cnblogs.com/tsoorr/p/3407935.html

http://www.cnblogs.com/ithouge/articles/ithouge-android-layer-list-shape-corners.html

http://www.linuxidc.com/Linux/2012-05/59827.htm

Android layer-list的属性和使用具体解释的更多相关文章

  1. android中xml tools属性详解

    第一部分 安卓开发中,在写布局代码的时候,ide可以看到布局的预览效果. 但是有些效果则必须在运行之后才能看见,比如这种情况:TextView在xml中没有设置任何字符,而是在activity中设置了 ...

  2. 如果需要将UIView的4个角全部都为圆角,做法相当简单,只需设置其Layer的cornerRadius属性即可

    如果需要将UIView的4个角全部都为圆角,做法相当简单,只需设置其Layer的cornerRadius属性即可(项目需要使用QuartzCore框架).而若要指定某几个角(小于4)为圆角而别的不变时 ...

  3. Android读取自定义View属性

    Android读取自定义View属性 attrs.xml : <?xml version="1.0" encoding="utf-8"?> < ...

  4. android中xmlns:tools属性详解

    今天读到一篇总结的非常棒的文章,写的逻辑很清晰也很实用,很少见到如此棒的文章了.就原文转发过来,我把格式给整理了一下,分享给园子里的各位朋友!好久没写博客了,就为2015年的11月留份纪念吧.希望对你 ...

  5. Mono for Android布局控件属性小结

    1. layout_weight 用于给一个线性布局中的诸多视图的重要度赋值. 所有的视图都有一个layout_weight值,默认为零,意思是需要显示 多大的视图就占据多大的屏幕空 间.若赋一个高于 ...

  6. 【Android】使用persist属性来调用脚本文件

    Android系统中有许多属性,属性由两个部分组成:name & value,可以使用这些属性来记录系统设置或进程之间的信息交换.Android系统在启动过程时会按序从以下几个文件中加载系统属 ...

  7. Android开发之EditText属性详解

    1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: 把该EditText设为:android:password="true" // 以”.”形式显示文本 ( ...

  8. android控件的属性

    android控件的属性 本节描述android空间的位置,内容等相关属性及属性的含义 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 ( ...

  9. 【转】 Android开发之EditText属性详解

    原文网址:http://blog.csdn.net/qq435757399/article/details/7947862 1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: ...

  10. Android中的windowSoftInputMode属性详解

    这篇文章主要介绍了Android中的windowSoftInputMode属性详解,本文对windowSoftInputMode的9个属性做了详细总结,需要的朋友可以参考下     在前面的一篇文章中 ...

随机推荐

  1. logrotate---日志分割

    logrotate命令用于对系统日志进行轮转.压缩和删除,也可以将日志发送到指定邮箱.使用logrotate指令,可让你轻松管理系统所产生的记录文件.每个记录文件都可被设置成每日,每周或每月处理,也能 ...

  2. 抓包神器Fiddler之Https请求随心转

    随着AppleStore对APP的审核越来越严格,客户端请求服务端API的方式大多数都变更为了https,在更安全的同时又引起了另外一个问题——本地抓包开发调试的不便. 一般来说,我们在开发API的时 ...

  3. .Net 开源控件 NPlot使用小结

    NPlot是一款非常难得的.Net平台下的图表控件,能做各种曲线图,柱状图,饼图,散点图,股票图等,而且它免费又开源,使用起来也非常符合程序员的习惯.授权方式为BSD许可证. 下载链接: http:/ ...

  4. [AngularFire] Resolve snapshotChanges doesn't emit value when data is empty

    Updated to AngularFire2 v5.0. One important change is that you need to call .snapshotChanges() or .v ...

  5. Lightoj 1127 - Funny Knapsack 【二分】

    题目链接:problem=1127">http://www.lightoj.com/volume_showproblem.php?problem=1127 题意:有n个物体(n< ...

  6. Git管理软件

    软件下载地址 首先下载库 https://code.google.com/p/msysgit/ 接着安装 https://code.google.com/p/tortoisegit/ 然后就能够用了

  7. jQuery UI:邮箱自动补全函数

    $('#email').autocomplete({ delay:0, autoFocus:true, source:function(request,response){ var hosts = [ ...

  8. go语言函数作为参数传递

    go语言函数作为参数传递,目前给我的感觉几乎和C/C++一致.非常的灵活. import "fmt" import "time" func goFunc1(f ...

  9. 2018-8-10 模拟赛T3(可持久化线段树)

    出题人说:正解离线按DFS序排序线段维护区间和 但是对于树上每个点都有一个区间和一个值,两个点之间求1~m的区间和,这不就是用可持久化线段树吗. 只不过这个线段树需要区间修改,不过不需要标记下传,询问 ...

  10. Mybaits中session的应用一

    获取一级缓存session SqlSession session = this.yangchebaoDbManagerImpl.getSqlSessionFactory().openSession(f ...