系统的Drawable(四)-LayerListDrawable

学习自

https://blog.csdn.net/u014695188/article/details/52815444

LayerListDrawable 漫谈

使用layer-list可以将多个drawable按照顺序层叠在一起显示,默认情况下,所有的item中的drawable都会自动根据它附上view的大小而进行缩放。巧妙的利用此Drawable,我们可以实现丰富的效果。

实现Tab效果

TabDrawable

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--非选中状态下的Drawable-->
<item android:state_checked="false">
<!--蓝色衬底-->
<layer-list>
<item>
<color android:color="#4144d6" />
</item>
<!--白色覆盖蓝色衬底,同时向上偏移一些,漏出下面的蓝色衬底-->
<item android:bottom="2dp">
<color android:color="#FFF" />
</item>
</layer-list>
</item>
<!--选中状态下的Drawable-->
<item android:state_checked="true">
<layer-list>
<!--蓝色衬底-->
<item>
<color android:color="#4144d6" />
</item>
<!--
白色覆盖蓝色衬底,
同时向上偏移一些,漏出下面的蓝色衬底
选中状态下的蓝色衬底要比非选中状态下的蓝色衬底要多一些
以视区别
-->
<item android:bottom="4dp">
<color android:color="#FFF" />
</item>
</layer-list>
</item> </selector>

Activity的布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context="com.example.it.studynotification.MainActivity"> <RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <RadioButton
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:background="@drawable/tab"
android:button="@null"
android:checked="false"
android:gravity="center"
android:text="Music" /> <RadioButton
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:background="@drawable/tab"
android:button="@null"
android:checked="false"
android:gravity="center"
android:text="Video" /> <RadioButton
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:background="@drawable/tab"
android:button="@null"
android:checked="false"
android:gravity="center"
android:text="Book" />
</RadioGroup>
</LinearLayout>

实现带阴影的Button

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--灰色的衬底,用来当做阴影-->
<item>
<shape>
<corners android:radius="10dp" />
<solid android:color="#eddfdf" />
</shape>
</item>
<!--
使用粉色将灰色覆盖的同时露出一点灰色
形成阴影效果
-->
<item android:bottom="5dp">
<shape>
<corners android:radius="10dp" />
<solid android:color="#efbcbc" />
</shape>
</item>
</layer-list>

系统的Drawable(四)-LayerListDrawable的更多相关文章

  1. 系统的Drawable(一)

    系统的Drawable(一) 学习自 <Android 开发艺术探索> <官方文档> https://www.cnblogs.com/popfisher/p/6238119.h ...

  2. Android系统--输入系统(十四)Dispatcher线程情景分析_dispatch前处理

    Android系统--输入系统(十四)Dispatcher线程情景分析_dispatch前处理 1. 回顾 我们知道Android输入系统是Reader线程通过驱动程序得到上报的输入事件,还要经过处理 ...

  3. 系统的Drawable(二)-Selector

    系统的Drawable(二)-Selector Selector漫谈 Selector是定义 StateListDrawable 的标签,该Drawable代表着一个Drawable的集合,每一个Dr ...

  4. 我是如何一步步编码完成万仓网ERP系统的(四)登录的具体实现

    https://www.cnblogs.com/smh188/p/11533668.html(我是如何一步步编码完成万仓网ERP系统的(一)系统架构) https://www.cnblogs.com/ ...

  5. Ubuntu 中查看内核版本和系统版本的四个命令

    一.查看内核版本:cat /proc/version 二.查看内核版本:uname -a 三.查看系统版本:lsb_release -a 四.查看发行版类型:cat /etc/issue

  6. 简单的web三层架构系统【第四版】

    上一次写了第三版, 因为之前无意之间看到一段视频,说是把系统中所有的SQL语句都做成存储过程.可以在很大程度上优化系统的SQL执行速度.所以百度了一下细节问题,之后我把所有的SQL语句,都做成了存储过 ...

  7. Java中获取系统时间的四种方式

    第一种: Date day=new Date(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" ...

  8. CRM系统(第四部分)

      阅读目录 1.引入权限组件rbac 2.分配权限 3.登录.引入中间件 1.引入权限组件rbac 1.settings配置app.中间件   INSTALLED_APPS = [ ... ... ...

  9. iOS 系统架构及常用框架(iOS的系统架构分为四个层次)

    1.iOS基于UNIX系统,因此从系统的稳定性上来说它要比其他操作系统的产品好很多 2.iOS的系统架构分为四层,由上到下一次为:可触摸层(Cocoa Touch layer).媒体层(Media l ...

随机推荐

  1. spring in action 学习笔记八:用@Primary 或者@Qualifier消除@Autowired引起的歧义现象

    首先解释一下@Primary和@Qualifier这两个注解的意思:@Primary的意思是在众多相同的bean中,优先使用用@Primary注解的bean.而@Qualifier这个注解则指定某个b ...

  2. mybatis与分布式事务的面试

    mybatis的面试: https://www.cnblogs.com/huajiezh/p/6415388.html 本地事务与分布式事务: https://www.cnblogs.com/xcj2 ...

  3. np.random.choice方法

    np.random.choice方法 觉得有用的话,欢迎一起讨论相互学习~Follow Me def choice(a, size=None, replace=True, p=None) 表示从a中随 ...

  4. Codeforces 666 B. World Tour

    http://codeforces.com/problemset/problem/666/B 题意: 给定一张边权均为1的有向图,求四个不同的点A,B,C,D,使得dis[A][B]+dis[B][C ...

  5. Splay模板讲解及一些题目

    普通平衡树模板以及文艺平衡树模板链接. 简介 平衡二叉树(Balanced Binary Tree)具有以下性质:它是一棵空树或它的左右两个子树的高度差的绝对值不超过1,并且左右两个子树都是一棵平衡二 ...

  6. vsftp服务器部署

    环境:CentOS 6.6 目标:个人虚机部署vsftp服务器,供测试使用. 说明:步骤已改写为脚本,直接添加用户与对应的密码列表,调用函数名即可 ########################## ...

  7. 记一次ThreadPoolExecutor面试

    ThreadPoolExecutor点滴 线程池应该也是面试绕不开的一个点,平时大家也没少用,但其实也有一些小Tips还是值得记录一下. Constructor public ThreadPoolEx ...

  8. 记一次HashMap面试

    记一次HashMap面试 从网上已经身边同事朋友的面试情况来看,面试HashMap几乎是必问的,网上也很多类似的文章,但是真面起来,发现还是有很多点可以深抠的.本篇就结合一次面试经历说一下之前没有注意 ...

  9. NEERC Southern Subregional 2011

    NEERC Southern Subregional 2011 A - Bonnie and Clyde solution 双指针搞搞就好. 时间复杂度:\(O(n)\) B - Building F ...

  10. WCF服务安全控制之netTcpBinding的用户名密码验证【转】

    选择netTcpBinding WCF的绑定方式比较多,常用的大体有四种: wsHttpBinding basicHttpBinding netTcpBinding wsDualHttpBinding ...