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. call 方法和 apply方法

    1.方法定义 call方法: 语法:call([thisObj[,arg1[, arg2[,   [,.argN]]]]]) 定义:调用一个对象的一个方法,以另一个对象替换当前对象. 说明: call ...

  2. 配置Lotus Domino集群视频详解

    IBM Lotus Domino Server 有个最重要的高可用特新就是集群,它对于任何使用 Domino 服务器的组织,让用户能够持续访问它们的数据库,保证业务不间断运行.下面通过两个视频来学习如 ...

  3. javafx clipboard

    public class EffectTest extends Application { public static void main(String[] args) { launch(args); ...

  4. Python 3 与"Hello World!"

    Python 3 版本 Python的3.0版本,常被称为Python 3000,或简称Py3k.相对于Python的早期版本,这是一个较大的升级.为了不带入过多的累赘,Python 3.0在设计的时 ...

  5. Android模拟、实现、触发系统按键事件的方法

     Android模拟.实现.触发系统按键事件的方法 /** * 模拟系统按键. * * @param keyCode */ public static void onKeyEvent(final ...

  6. MVC—实现ajax+mvc异步获取数据

    之前写过ajax和一般处理程序的结合实现前后台的数据交换的博客,如今做系统用到了MVC,同一时候也用到了异步获取数据. ajax+一般处理程序与MVC+ajax原理是一样的在"URL&quo ...

  7. js22--链式调用

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  8. 关于EJB--实体Bean的BMP和CMP选择

    EJB有两种主要类型BMP(Bean managed persistence )和CMP(Container managed persistence ),这两种类型各有优缺点. BMP是在Bean中完 ...

  9. Linux中iptables学习

    防火墙:是一种位于内部网络与外部网络之间安全的防护系统,依照特定的规则,允许或是限制传输的数据通过.iptables通常被用作类UNIX系统中的防火墙,更准确的说,可以称为iptables/netfi ...

  10. android 仿ios 对话框已封装成工具类

    对话框 在android中是一种非经常见的交互提示用户的方式,可是非常多产品狗都叫我们这些做android的仿ios,搞的我们android程序猿非常苦逼,凭什么效果老是仿ios,有没有一点情怀,只是 ...