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. android 图片特效处理之 光晕效果

    这篇将讲到图片特效处理的图片光晕效果.跟前面一样是对像素点进行处理,本篇实现的思路可参见android图像处理系列之九--图片特效处理之二-模糊效果和android图像处理系列之十三--图片特效处理之 ...

  2. wget---从指定的URL下载文件

    wget命令用来从指定的URL下载文件.wget非常稳定,它在带宽很窄的情况下和不稳定网络中有很强的适应性,如果是由于网络的原因下载失败,wget会不断的尝试,直到整个文件下载完毕.如果是服务器打断下 ...

  3. 今日题解------codeforce 893d

    题意:给你一个数列,小于零表示表示信用卡里取出钱,大于零表示信用卡里存钱,等于零表示要查询信用卡, 如果被查到信用卡里的钱小于零,那你就GG,或者在任何时候你的信用卡里的钱大于d的话(不需要找ai等于 ...

  4. Python - 字典(dict)删除元素

    字典(dict)删除元素, 能够选择两种方式, dict.pop(key)和del dict[key]. 代码 # -*- coding: utf-8 -*- def remove_key(d, ke ...

  5. [Java开发之路](16)学习log4j日志

    1. 新建一个Javaproject.导入Jar包(log4j-1.2.17.jar) Jar包下载地址:点击打开链接 2. 配置文件:创建并设置log4j.properties # 设置 log4j ...

  6. javascript创建对象的方法--组合模式

    javascript创建对象的方法--组合模式 一.总结 0.作用:解决原型模式对象独有属性创建麻烦的问题 1.组合模式使用普遍:jquery就是用的组合模式,组合模式使用非常普遍 2.组合模式优点: ...

  7. 【Codeforces Round #452 (Div. 2) B】Months and Years

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 闰,平,平 平,闰,平 平,平,闰 平,平,平 4种情况都考虑到就好. 可能有重复的情况. 但是没关系啦. [代码] #includ ...

  8. Native开发与JNI机制详解

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 文/李森 博主导读:博主不是代码大师,研究什么都很深,Java除外,所以无论什么问题,方案可以提供, ...

  9. asp.net Code学习二(使用vs 2015 update 3)

    1.在vs 2015上搭建asp.net core:  安装 .Net core sdk.vs2015 tool 即可使用vs 2015开发asp.net core. 2.Net core中国学习小组 ...

  10. GraphX 图数据建模和存储

    背景 简单分析一下GraphX是怎么为图数据建模和存储的. 入口 能够看GraphLoader的函数. def edgeListFile( sc: SparkContext, path: String ...