您的位置:首页 > 移动开发 > Android开发

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: