Android layer-list(3)
Android layer-list(3)
在附录文章3、4的基础上,就Android layer-list再写一个较为复杂的应用。
先写布局文件,该布局涉及到LinearLayoutCompat,关于LinearLayoutCompat参看附录文章5。
布局文件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"
android:background="@android:color/holo_orange_light"
tools:context="zhangphil.demo.MainActivity"> <android.support.v7.widget.LinearLayoutCompat xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dip"
android:background="@drawable/layer_list"
android:orientation="vertical"
app:divider="@drawable/shape"
app:dividerPadding="50dip"
app:showDividers="middle"> <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="zhang phil @csdn" /> <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="zhang phil @csdn" /> <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="zhang phil @csdn" /> <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="zhang phil @csdn" /> <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="zhang phil @csdn" /> <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="zhang phil @csdn" /> <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="zhang phil @csdn" /> </android.support.v7.widget.LinearLayoutCompat>
</RelativeLayout>
其中activity_main.xml中的LinearLayoutCompat涉及到了添加分割线,需要再写一个shape文件,drawable/shape.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@android:color/darker_gray" /> <!-- 分割线的高度 -->
<size android:height="2dip" /> </shape>
drawable/layer_list.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item>
<shape>
<corners
android:bottomLeftRadius="20dip"
android:bottomRightRadius="20dip"
android:topLeftRadius="20dip"
android:topRightRadius="20dip" />
<solid android:color="@android:color/background_light" /> <stroke
android:width="2dip"
android:color="@android:color/darker_gray" />
</shape>
</item> <item android:drawable="@mipmap/ic_launcher"></item> </layer-list>
代码运行结果:
附录文章:
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
3,《Android layer-list(1)》链接地址:http://blog.csdn.net/zhangphil/article/details/51720924
4,《Android layer-list:联合shape(2)》链接地址:http://blog.csdn.net/zhangphil/article/details/51721283
5,《Android Material Design :LinearLayoutCompat添加分割线divider》链接地址:http://blog.csdn.net/zhangphil/article/details/48899585
Android layer-list(3)的更多相关文章
- Android 蓝牙开发(3)——蓝牙的详细介绍
前面的两篇文章,主要是在 Android 官网关于蓝牙介绍的基础上加上自己的理解完成的.主要针对的是 Android 开发中的一些 API 的使用. 第一篇文章 Android 蓝牙开发(1) 主要是 ...
- 浅谈Android应用保护(一):Android应用逆向的基本方法
对于未进行保护的Android应用,有很多方法和思路对其进行逆向分析和攻击.使用一些基本的方法,就可以打破对应用安全非常重要的机密性和完整性,实现获取其内部代码.数据,修改其代码逻辑和机制等操作.这篇 ...
- Android 自定义View (五)——实践
前言: 前面已经介绍了<Android 自定义 view(四)-- onMeasure 方法理解>,那么这次我们就来小实践下吧 任务: 公司现有两个任务需要我完成 (1)监测液化天然气液压 ...
- Android 自定义 view(四)—— onMeasure 方法理解
前言: 前面我们已经学过<Android 自定义 view(三)-- onDraw 方法理解>,那么接下我们还需要继续去理解自定义view里面的onMeasure 方法 推荐文章: htt ...
- Android 自定义 view(三)—— onDraw 方法理解
前言: 上一篇已经介绍了用自己定义的属性怎么简单定义一个view<Android 自定义view(二) -- attr 使用>,那么接下来我们继续深究自定义view,下一步将要去简单理解自 ...
- Android Animation学习(六) View Animation介绍
Android Animation学习(六) View Animation介绍 View Animation View animation系统可以用来执行View上的Tween animation和F ...
- Android Animation学习(五) ApiDemos解析:容器布局动画 LayoutTransition
Android Animation学习(五) ApiDemos解析:容器布局动画 LayoutTransition Property animation系统还提供了对ViewGroup中的View改变 ...
- Android Animation学习(四) ApiDemos解析:多属性动画
Android Animation学习(四) ApiDemos解析:多属性动画 如果想同时改变多个属性,根据前面所学的,比较显而易见的一种思路是构造多个对象Animator , ( Animator可 ...
- Android Animation学习(三) ApiDemos解析:XML动画文件的使用
Android Animation学习(三) ApiDemos解析:XML动画文件的使用 可以用XML文件来定义Animation. 文件必须有一个唯一的根节点: <set>, <o ...
- Android Animation学习(二) ApiDemos解析:基本Animators使用
Android Animation学习(二) ApiDemos解析:基本Animatiors使用 Animator类提供了创建动画的基本结构,但是一般使用的是它的子类: ValueAnimator.O ...
随机推荐
- bzoj 2763: [JLOI2011]飞行路线【分层图+spfa】
为什么早年的题总是从0开始标号啊--又zz了一次WA 分层图的题只有这一个套路吧,建分层图,然后优化时间是分层跑spfa然后层与层之间单独跑即可 #include<iostream> #i ...
- HTML5常用知识点
github代码:https://github.com/showkawa/H5C3/tree/master/html5 1.自定义属性 data- 1.1 可以给html里的所有DOM对象都可以添加一 ...
- Linux 常规操作指南
1.修改Linux服务器别名 临时修改: vim /etc/hostname 修改别名 永久修改: vim /etc/sysconfig/network 添加 HOSTNAME=别名 重启服务器 ...
- Codeforces 1131 (div 2)
链接:http://codeforces.com/contest/1131 A Sea Battle 利用良心出题人给出的图,不难看出答案为\(2*(h1+h2)+2*max(w1,w2)+4\)由于 ...
- windows 定时任务 设置 安全事项
windows 定时任务 设置 安全事项 1.如果是oaadmin/administrator 创建oracle 数据库. 安全选项如下: 1.只是在用户登录时候运行. sample: data ho ...
- MySql数据库存储emoji表情报错解决办法
异常:java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' for column 'name' at row 1 解决: ...
- java项目怎么打jar包(项目中包含第三方jar包)
1,右键选中项目,点击Export导出,找到java,选择第三个Runnable JAR file, 2,在Launch configuration中,填入程序的入口(有main方法的类), 然后 ...
- 简单谈谈MySQL中的int(m)
转载地址:https://www.jb51.net/article/93760.htm 设置int型的时候,需要设置int(M),以前知道这个M最大是255,但是到底应该设置多少并没有在意.注意zer ...
- Android APK瘦身之webp图片
webp格式是谷歌推出的一种有损压缩格式,这种图片格式相比png或者jpg格式的图片损失的质量几乎可以忽略不计,但是压缩后图片的体积却比png或者jpg要小很多.亲测一个100kb的png图片经过we ...
- interface与抽象类
抽象类: 定义:在 class 前加了 abstract 关键字且存在抽象方法(在类方法 function 关键字前加了 abstract 关键字)的类 抽象类不能被实例化. 抽象类被继承之后,子类必 ...