Android layer-list(1)
2016-06-20 15:16
351 查看
Android layer-list(1)
Android layer-list,顾名思义,实现列表组合后形成的图层,写一个例子。
activity_main.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="zhangphil.demo.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="150dip"
android:layout_centerInParent="true"
android:background="@drawable/layer_list"
android:text="zhang phil @csdn"
android:gravity="center"
android:textColor="@android:color/white"/>
</RelativeLayout>
其中TextView background需要的背景资源就是一个layer-list,位于drawable目录下的layer_list.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/holo_red_light"></item>
<item android:drawable="@mipmap/ic_launcher"></item>
</layer-list>注意layer-list里面定义的item元素的先后顺序,后者将直接覆盖在前者上面,一层一层覆盖。
代码运行结果:
附录文章:
1,《Android AnimationDrawable动画与APP启动引导页面》链接地址:http://blog.csdn.net/zhangphil/article/details/47416915
2,《Android ImageView的setImageLevel和level-list使用简介》链接地址:http://blog.csdn.net/zhangphil/article/details/48936209
Android layer-list(1)
Android layer-list,顾名思义,实现列表组合后形成的图层,写一个例子。
activity_main.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="zhangphil.demo.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="150dip"
android:layout_centerInParent="true"
android:background="@drawable/layer_list"
android:text="zhang phil @csdn"
android:gravity="center"
android:textColor="@android:color/white"/>
</RelativeLayout>
其中TextView background需要的背景资源就是一个layer-list,位于drawable目录下的layer_list.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/holo_red_light"></item>
<item android:drawable="@mipmap/ic_launcher"></item>
</layer-list>注意layer-list里面定义的item元素的先后顺序,后者将直接覆盖在前者上面,一层一层覆盖。
代码运行结果:
附录文章:
1,《Android AnimationDrawable动画与APP启动引导页面》链接地址:http://blog.csdn.net/zhangphil/article/details/47416915
2,《Android ImageView的setImageLevel和level-list使用简介》链接地址:http://blog.csdn.net/zhangphil/article/details/48936209
相关文章推荐
- Android layer-list(1)
- Android实现支持所有View的通用的下拉刷新控件
- Android漂亮的对话框项目sweet-alert-dialog
- Android图片裁剪库——cropper使用,完美解决图片填充不满布局问题
- Android内存优化之OOM
- Android Log日志
- android 自定义控件 使用declare-styleable进行配置属性(源码角度)
- Android将debug.keystore改为和发布的key的sha1签名一样
- Introducing Android Instant Apps - Google I-O 2016 翻译字幕
- android 获取状态栏的高度
- Android 基于ImageSwitcher实现的左右切换图片
- android-----XUtils框架之BitmapUtils加载照片实现
- Android studio 异常 libpng warning: iCCP: Not recognizing known sRGB profile that has be
- Android照片墙完整版,完美结合LruCache和DiskLruCache
- Android之SurfaceView学习(一)
- Android DiskLruCache完全解析,硬盘缓存的最佳方案
- Android初级教程启动定时器详解
- android 5.0以上通知栏、状态栏图标变成白色
- [已解决]Android studio git报错 could not read from remote repository
- 【转】android中ListView的定位:使用setSelectionFromTop实现ListView的position的保持