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)的更多相关文章

  1. Android 蓝牙开发(3)——蓝牙的详细介绍

    前面的两篇文章,主要是在 Android 官网关于蓝牙介绍的基础上加上自己的理解完成的.主要针对的是 Android 开发中的一些 API 的使用. 第一篇文章 Android 蓝牙开发(1) 主要是 ...

  2. 浅谈Android应用保护(一):Android应用逆向的基本方法

    对于未进行保护的Android应用,有很多方法和思路对其进行逆向分析和攻击.使用一些基本的方法,就可以打破对应用安全非常重要的机密性和完整性,实现获取其内部代码.数据,修改其代码逻辑和机制等操作.这篇 ...

  3. Android 自定义View (五)——实践

    前言: 前面已经介绍了<Android 自定义 view(四)-- onMeasure 方法理解>,那么这次我们就来小实践下吧 任务: 公司现有两个任务需要我完成 (1)监测液化天然气液压 ...

  4. Android 自定义 view(四)—— onMeasure 方法理解

    前言: 前面我们已经学过<Android 自定义 view(三)-- onDraw 方法理解>,那么接下我们还需要继续去理解自定义view里面的onMeasure 方法 推荐文章: htt ...

  5. Android 自定义 view(三)—— onDraw 方法理解

    前言: 上一篇已经介绍了用自己定义的属性怎么简单定义一个view<Android 自定义view(二) -- attr 使用>,那么接下来我们继续深究自定义view,下一步将要去简单理解自 ...

  6. Android Animation学习(六) View Animation介绍

    Android Animation学习(六) View Animation介绍 View Animation View animation系统可以用来执行View上的Tween animation和F ...

  7. Android Animation学习(五) ApiDemos解析:容器布局动画 LayoutTransition

    Android Animation学习(五) ApiDemos解析:容器布局动画 LayoutTransition Property animation系统还提供了对ViewGroup中的View改变 ...

  8. Android Animation学习(四) ApiDemos解析:多属性动画

    Android Animation学习(四) ApiDemos解析:多属性动画 如果想同时改变多个属性,根据前面所学的,比较显而易见的一种思路是构造多个对象Animator , ( Animator可 ...

  9. Android Animation学习(三) ApiDemos解析:XML动画文件的使用

    Android Animation学习(三) ApiDemos解析:XML动画文件的使用 可以用XML文件来定义Animation. 文件必须有一个唯一的根节点: <set>, <o ...

  10. Android Animation学习(二) ApiDemos解析:基本Animators使用

    Android Animation学习(二) ApiDemos解析:基本Animatiors使用 Animator类提供了创建动画的基本结构,但是一般使用的是它的子类: ValueAnimator.O ...

随机推荐

  1. Moco模拟服务器post&get请求 (二)

    1.moco启动命令如下:java -jar moco-runner-0.12.0-standalone.jar 协议类型 -p 端口号 -c json配置文件 2.带参数的get请求 [ { &qu ...

  2. 在Chrome与火狐中,输入框input类型为number时,如何去除掉的自带的上下默认箭头

    如何移除input='number'时浏览器自带的上下箭头: CSS样式: /* 去除input[type=number]浏览器默认的icon显示 */ input::-webkit-outer-sp ...

  3. 讯搜问题排查xunsearch

    mysql导入数据不成功,开始重建索引后提示 [XSException] ../local/xunsearch/sdk/php/lib/XS.php(1898): DB- 可打印的版本 开始重建索引 ...

  4. 类似QQ消息左滑删除的Demo

    最近在网上学到一篇类似QQ消息左滑删除的demo,完善了下代码,感觉还不错,特此分享一波: CustomSwipeListView.java 是个继承自ListView的类,里面调用了自定义View ...

  5. [读书笔记2]《C语言嵌入式系统编程修炼》

    第3章 屏幕操作   3.1 汉字处理 现在要解决的问题是,嵌入式系统中经常要使用的并非是完整的汉字库,往往只是需要提供数量有限的汉字供必要的显示功能.例如,一个微波炉的LCD上没有必要提供显示&qu ...

  6. ACM_同余+暴力找规律

    小光的忧伤 Time Limit: 2000/1000ms (Java/Others) Problem Description: 锴神:我尊重作者原意,你们出什么我就加什么.于是小光打了道水题(也就是 ...

  7. 石墨烯(转自wiki)

    石墨烯(Graphene)是一种由碳原子以sp2杂化轨道组成六角型呈蜂巢晶格的平面薄膜,只有一个碳原子厚度的二维材料[1].石墨烯一直被认为是假设性的结构,无法单独稳定存在[1],直至2004年,英国 ...

  8. 【转】HIVE UDF UDAF UDTF 区别 使用

    原博文出自于:http://blog.csdn.net/longzilong216/article/details/23921235(暂时) 感谢! 自己写代码时候的利用到的模板   UDF步骤: 1 ...

  9. [ USACO 2007 FEB ] Lilypad Pond (Silver)

    \(\\\) \(Description\) 一张\(N\times M\)的网格,已知起点和终点,其中有一些地方是落脚点,有一些地方是空地,还有一些地方是坏点. 现在要从起点到终点,每次移动走日字\ ...

  10. CSS笔记集合

    CSS CSS 认识 CSS全称为层叠样式表,主要是用于定义HTML内容在浏览器内的显示样式. CSS样式由选择符和声明组成,而声明又由属性和值组成. CSS中注释语句:/*注释语句*/.Html中使 ...