当前位置: 首页 > news >正文

Android layer-list的属性和使用具体解释

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


相关文章:

  • 安全地关闭 jvm(tomcat停止钩子事件处理)
  • 智慧医疗“验血查癌”或会实现
  • shell脚本练习题
  • 沉浸式状态栏解析
  • 若要允许 GET 请求,请将 JsonRequestBehavior 设置为 AllowGet
  • Spring Cloud微服务分布式云架构简介
  • centos7 mysql 5.7 yum安装
  • Maven单独构建多模块项目中的单个模块
  • 常用页面校验整合
  • java spring事务管理相关
  • HTML5 a标签的download属性
  • 正向代理,反向代理(图片解析)
  • nginx常用命令
  • 雾计算简史
  • php memcached(windows linux) 的安装及应用 2011-04-08
  • [iOS]Core Data浅析一 -- 启用Core Data
  • [微信小程序] 使用ES6特性Class后出现编译异常
  • js如何打印object对象
  • nginx 配置多 域名 + 多 https
  • Quartz初级教程
  • supervisor 永不挂掉的进程 安装以及使用
  • vagrant 添加本地 box 安装 laravel homestead
  • 持续集成与持续部署宝典Part 2:创建持续集成流水线
  • 简单实现一个textarea自适应高度
  • 今年的LC3大会没了?
  • 数据科学 第 3 章 11 字符串处理
  • 我建了一个叫Hello World的项目
  • 一个完整Java Web项目背后的密码
  • 一个项目push到多个远程Git仓库
  • 以太坊客户端Geth命令参数详解
  • ​力扣解法汇总946-验证栈序列
  • (1)(1.13) SiK无线电高级配置(六)
  • (6)STL算法之转换
  • (c语言)strcpy函数用法
  • (超简单)构建高可用网络应用:使用Nginx进行负载均衡与健康检查
  • (附源码)springboot青少年公共卫生教育平台 毕业设计 643214
  • (附源码)计算机毕业设计ssm本地美食推荐平台
  • (黑客游戏)HackTheGame1.21 过关攻略
  • (力扣)1314.矩阵区域和
  • (算法)N皇后问题
  • ..thread“main“ com.fasterxml.jackson.databind.JsonMappingException: Jackson version is too old 2.3.1
  • .a文件和.so文件
  • .xml 下拉列表_RecyclerView嵌套recyclerview实现二级下拉列表,包含自定义IOS对话框...
  • @AutoConfigurationPackage的使用
  • @EnableConfigurationProperties注解使用
  • @hook扩展分析
  • [.NET]桃源网络硬盘 v7.4
  • [Android]竖直滑动选择器WheelView的实现
  • [C++从入门到精通] 14.虚函数、纯虚函数和虚析构(virtual)
  • [CC2642R1][VSCODE+Embedded IDE+IAR Build+Cortex-Debug] TI CC2642R1基于VsCode的开发环境
  • [dart学习]第四篇:函数
  • [JS]Math.random()随机数的二三事
  • [paddle]ModuleNotFoundError: No module named ‘paddle.nn.layer.layers
  • [python开发模拟netcat工具] BHPnet
  • [RoarCTF 2019]Easy Calc