Android layer-list的属性和使用详解




http://www.codes51.com/article/detail_163095.html

http://www.codes51.com/article/detail_163095.htmlhttp://www.codes51.com/article/detail_163095.htmlhttp://www.codes51.com/article/detail_163095.html

http://www.codes51.com/article/detail_163095.html

http://www.codes51.com/article/detail_163095.html

http://www.codes51.com/article/detail_163095.html





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>

效果图

Android layer-list的属性和使用详解_第1张图片

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的属性和使用详解,包括了方面的内容,希望对Android开发有兴趣的朋友有所帮助。

本文网址链接:http://www.codes51.com/article/detail_163095.html

电脑/手机小常识:自动打开Windows资源管理器
有些情况下,借助Windows资源管理器来浏览文件夹要比直接打开每个文件夹并查看其中内容更加直观方便。一般我们可以在文件夹上单击鼠标右键并从中选择资源管理器,然而如果你有双击鼠标的操作习惯,那么我们还能够以更加快捷的方式打开文件夹。首先打开我的电脑,从工具菜单中选择“文件夹选项”,单击“文件类型”选项卡。在文件类型列表中,选择“文件夹”并单击“高级”按钮,在编辑文件类型对话框中,选择资源管理器,并单击“设为默认值”按钮。单击“确定”之后,再单击关闭。现在,当你在任意文件夹上进行双击时,将自动打开Windows资源管理器视图。





你可能感兴趣的:(Android layer-list的属性和使用详解)