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"><TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:text="zhang phil @csdn" /><TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:text="zhang phil @csdn" /><TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:text="zhang phil @csdn" /><TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:text="zhang phil @csdn" /><TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:text="zhang phil @csdn" /><TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:text="zhang phil @csdn" /><TextViewandroid: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><cornersandroid:bottomLeftRadius="20dip"android:bottomRightRadius="20dip"android:topLeftRadius="20dip"android:topRightRadius="20dip" /><solid android:color="@android:color/background_light" /><strokeandroid: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布局优化(上)

    前言 成为一名优秀的Android开发,需要一份完备的知识体系,在这里,让我们一起成长为自己所想的那样~. Android的绘制优化其实可以分为两个部分,即布局(UI)优化和卡顿优化,而布局优化的核心 ...

  2. Android硬件加速(二)-RenderThread与OpenGL GPU渲染

    Android4.0之后,系统默认开启硬件加速来渲染视图,之前,理解Android硬件加速的小白文简单的讲述了硬件加速的简单模型,不过主要针对前半阶段,并没怎么说是如何使用OpenGL.GPU处理数据 ...

  3. Android车载系统(HVAC) 原理+源码分析(代码示例)

    前言 Android车载系统(HVAC)是一种用于控制车内温度.空气质量和湿度的系统,它是一项重要的汽车电子技术.在这种系统中,CarHvacManager控制器是一个重要的组件,它通过与车载传感器和 ...

  4. Android读写XML(上)

    XML 经常用作 Internet 上的一种数据格式,其文件格式想必大家都比较清楚,在这里我结合Android平台,来说明Android SDK提供的读写XML的package. 首先介绍下Andro ...

  5. Android API 中文 (51) —— ZoomButtonsController

    一.结构 public class ZoomButtonsController extends View implements View.OnTouchListener java.lang.Objec ...

  6. Android测试原理(三)——使用Eclipse的ADT进行测试

    原文链接:http://developer.android.com/tools/testing/testing_eclipse.html 1.使用Eclipse的ADT进行测试 这次的主题介绍了怎么使 ...

  7. Android项目实战(四):ViewPager切换动画(3.0版本以上有效果)

    原文:Android项目实战(四):ViewPager切换动画(3.0版本以上有效果) 学习内容来自"慕课网" 一般APP进去之后都会有几张图片来导航,这里就学习怎么在这张图片切换 ...

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

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

  9. Android下载文件(一)下载进度断点续传

    Android下载文件(一)下载进度&断点续传 索引 Android下载文件(一)下载进度&断点续传 Android下载文件(二)单任务多线程并发&断点续传(待续) Andro ...

  10. 直接拿来用!最火的Android开源项目(一)

    2019独角兽企业重金招聘Python工程师标准>>> 摘要:对于开发者而言,了解当下比较流行的开源项目很是必要.利用这些项目,有时能够让你达到事半功倍的效果.为此,CSDN特整理了 ...

最新文章

  1. MYSQL数据文件--.frm文件(只有.frm文件时的表结构恢复)
  2. 日本地铁公益广告 拒绝三俗!
  3. 【编译打包】twemproxy-0.4.0-2.el7.centos.src.rpm
  4. 纪念逝去的岁月——C/C++字符串反转
  5. 现在的男生真的太惨了
  6. glassfish发布应用_GlassFish 4升级的构建,Gradle和嵌入式应用服务器
  7. 弱小无助!苹果或将出手救援屏幕供应商JDI
  8. https 方式使用git@osc设置密码的方式
  9. 30 万奖金悬赏 | CSDN 软件开发精英赛即日启动
  10. 浓缩的就是精华——ES6迭代器精炼讲解
  11. 2019年11月中华人民共和国县以上行政区划代码(用于身份证前六位判断户籍所在地)
  12. “磁碟机”病毒详尽分析报告
  13. 【disordered_zip】BUGKU
  14. 孔雀东南飞$追加x5淘宝JS
  15. java-斗地主无界面有序版
  16. CFDA《药品数据管理规范》疑难点解读
  17. threejs 使用陀螺仪实现手机端全景
  18. 做一个九宫格诗词答题小程序 (二)倒计时功能实现
  19. 苹果备忘录永久删除怎么恢复?分享2个找回备忘录的高效操作
  20. 商务服务-建站设计思路搜索引擎SEO模型

热门文章

  1. 如何删除被锁定的文件(一)他山工具篇 WhoLockMe?
  2. gitlab报错 fatal: index-pack failed error: RPC failed; result=18, HTTP code = 200解决方案
  3. Http环境下的保持连接方式
  4. Spring源码分析【4】-Spring扫描basePackages注解
  5. Linux环境ddd安装与使用
  6. FFmpeg中libswscale库简介及测试代码
  7. Linux中获取当前程序路径的方法
  8. OpenCV 2.2.0 CvvImage的使用
  9. 【C++】Google Protocol Buffer(protobuf)详解(二)
  10. android调用相册和摄像头,调用Android摄像头与打开相册