Android layer-list的使用
2016-01-18 17:06
399 查看
layer是在PS中非常常用的功能,是用来多个图层堆叠显示的。接下来做一个简单的例子:
点击左边条目 显示不同的背景。
正常时候的背景
点击时的背景:
再写一个selector
然后设置为背景,就可以实现上图的效果。
点击左边条目 显示不同的背景。
正常时候的背景
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item > <shape android:shape="rectangle"> <solid android:color="#e5e5e5" /> </shape> </item> //底部上移1dp 右边左移1dp 显示黑色线条 <item android:right="1dp" android:bottom="1dp"> <shape android:shape="rectangle"> <solid android:color="#f2f3f5"/> </shape> </item> </layer-list>
点击时的背景:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item > <shape android:shape="rectangle"> <solid android:color="#e5e5e5" /> </shape> </item> //底部上移1dp 右边没有 <item android:bottom="1dp"> <shape android:shape="rectangle"> <solid android:color="#ffffff" /> </shape> </item> </layer-list>
再写一个selector
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/selected" android:state_selected="true"></item> <item android:drawable="@drawable/normal"></item> </selector>
然后设置为背景,就可以实现上图的效果。
相关文章推荐
- Android圆形图片自定义控件
- Android&IOS学习路线图
- Android 元素属性
- Android 讲解:存储(2)
- Android Studio实现Service AIDL
- Android开发环境搭建
- Android魅族等手机下拉刷新有留白(下拉悬停)
- android onmeasure介绍
- android开源日志库的使用
- 《Android安全攻防权威指南》读书笔记
- Android基础_Spinner使用记录
- Android LayoutInflater深度解析
- 采用Matrix实现图片查看
- Android Volley框架的几种post提交请求方式
- Android Studio使用百度语音合成是TTS时报错: ****.so文件找不到的有关问题
- Android应用开发基础篇(3)-----ListView
- android中dialog中的EditText无法弹出输入法对话框
- mediaserver内存泄露分析
- Android应用开发基础篇(2)-----Notification(状态栏通知)
- Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml