Jeff Lee blog:   http://www.cnblogs.com/Alandre/  (泥沙砖瓦浆木匠),retain the url when reproduced ! Thanks

今天我们来Android UI第一讲:实现Layout 背景局部Shape圆角设计

效果图:

第一步:定义一个shape

res/drawable/shape_to_corner_no_bottom_line.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<!-- shape with circle-top corner -->
<shape>
<!-- the shape background color -->
<solid android:color="@color/black"/>
<corners android:topLeftRadius="10dp" android:topRightRadius="10dp"
android:bottomLeftRadius="0.1dp" android:bottomRightRadius="0.1dp"/>
<stroke android:width="1dp" android:color="@color/black"/>
</shape>
</item>
</layer-list>

其中参数含义:{英语单词顾名思义}

这是参数详解

 <!-- 圆角 -->
<corners
android:radius="9dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"/><!-- 设置圆角半径 --> <!-- 渐变 -->
<gradient
android:startColor="@android:color/white"
android:centerColor="@android:color/black"
android:endColor="@android:color/black"
android:useLevel="true"
android:angle="45"
android:type="radial"
android:centerX="0"
android:centerY="0"
android:gradientRadius="90"/> <!-- 间隔 -->
<padding
android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp"/><!-- 各方向的间隔 --> <!-- 大小 -->
<size
android:width="50dp"
android:height="50dp"/><!-- 宽度和高度 --> <!-- 填充 -->
<solid
android:color="@android:color/white"/><!-- 填充的颜色 --> <!-- 描边 -->
<stroke
android:width="2dp"
android:color="@android:color/black"
android:dashWidth="1dp"
android:dashGap="2dp"/>
填充:设置填充的颜色 间隔:设置四个方向上的间隔 大小:设置大小 圆角:同时设置五个属性,则Radius属性无效 android:Radius="20dp" 设置四个角的半径 android:topLeftRadius="20dp" 设置左上角的半径
android:topRightRadius="20dp" 设置右上角的半径
android:bottomLeftRadius="20dp" 设置右下角的半径
android:bottomRightRadius="20dp" 设置左下角的半径 描边:dashWidth和dashGap属性,只要其中一个设置为0dp,则边框为实现边框 android:width="20dp" 设置边边的宽度
android:color="@android:color/black" 设置边边的颜色
android:dashWidth="2dp" 设置虚线的宽度
android:dashGap="20dp" 设置虚线的间隔宽度

渐变:当设置填充颜色后,无渐变效果。angle的值必须是45的倍数(包括0),仅在type="linear"有效,不然会报错。android:useLevel 这个属性不知道有什么用。

第二步: Layout中设置

   android:background="@drawable/shape_to_corner_no_bottom_line"

这样就简单的设置好了。

Android UI(一)Layout 背景局部Shape圆角设计的更多相关文章

  1. [Android UI] shape和selector的结合使用

    shape和selector是Android UI设计中经常用到的,比如我们要自定义一个圆角Button,点击Button有些效果的变化,就要用到shape和selector.可以这样说,shape和 ...

  2. shape和selector是Android UI设计中经常用到的

    shape和selector是Android UI设计中经常用到的,比如我们要自定义一个圆角Button,点击Button有些效果的变化,就要用到shape和selector.可以这样说,shape和 ...

  3. Android UI学习 - ListView (android.R.layout.simple_list_item_1是个什么东西)

    Android UI学习 - ListView -- :: 标签:Android UI 移动开发 ListView ListActivity 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始 ...

  4. 各种Android UI开源框架 开源库

    各种Android UI开源框架 开源库 转 https://blog.csdn.net/zhangdi_gdk2016/article/details/84643668 自己总结的Android开源 ...

  5. 浅谈android的selector,背景选择器

    shape和selector的结合使用 (2013-04-07 11:11:00) 转载▼   分类: android 1.Shape (1)作用:XML中定义的几何形状 (2)位置:res/draw ...

  6. GitHub上受欢迎的Android UI Library

    GitHub上受欢迎的Android UI Library 内容 抽屉菜单 ListView WebView SwitchButton 按钮 点赞按钮 进度条 TabLayout 图标 下拉刷新 Vi ...

  7. Android学习系列(17)--App列表之圆角ListView(续)

    http://www.cnblogs.com/qianxudetianxia/archive/2011/09/19/2068760.html   本来这篇文章想并到上篇Android学习系列(16)- ...

  8. Android UI相关开源项目库汇总

    最近做了一个Android UI相关开源项目库汇总,里面集合了OpenDigg 上的优质的Android开源项目库,方便移动开发人员便捷的找到自己需要的项目工具等,感兴趣的可以到GitHub上给个st ...

  9. Android学习系列(16)--App列表之圆角ListView

    有些东西看多了,就厌烦了:extjs对我这种感觉最为强烈.甚至,有时觉得设计之殇是审美疲劳.直角看多了,就想看看圆角,不知何时,这几年刮起了一阵阵的圆角设计风:CSS新标准纳入圆角元素,iphone中 ...

随机推荐

  1. vue 图片下载到本地,图片保存到本地

    必须同源(访问的网站域名与服务器域名一致)才能下载 downs() { var alink = document.createElement("a"); alink.href = ...

  2. Linux学习---自定义数据类型

    struct   结构体 (地址递增) eg:struct myabc{ unsigned int a; unsigned int b; unsigned int c; unsigned int d; ...

  3. ES6使用fetch请求数据

    ie是完全不支持fetch的. fetch(url,{method:"get/post"}).then(res=>{   }) 如果请求返回的status是200,body是 ...

  4. C#运行时通过字符串实例化类对象

    备忘,记个C#版本. using System; using System.Collections.Generic; using System.Linq; using System.Text; usi ...

  5. 关于数据库连接时URL的问题

    最近在写一个简单的增删改查的代码时,遇到保存的中文都会变成问号(?),由于刚开始只是一些数据的保存,所以认为之后只要对数据库的编码进行修改即可,但是后来要对数据进行查找的时候发现根本查找不到, 当时用 ...

  6. log4j日志的使用

    1.引架包和导配置文件log4j.properties <dependency> <groupId>org.slf4j</groupId> <artifact ...

  7. javaWeb中MVC的编程思想示例

    没有学习MVC之前我只写了一个Servlet类(Note_List.java),分层之后,我将这个类分成了5个类(NoteDao.java,,NoteDaoImpl.java,,NoteService ...

  8. python基础自学 第三天

    变量的命名 01.标识符和关键字 标识符 标识符就是程序员定义的变量名.函数名. 标识符可以由字母,下划线,和数字组成. 不能以数字开头 不能与关键字重名 关键字 就是在python内部已经使用的标识 ...

  9. listcard记录

    .listcard-bg{ .listcard-head{ background: #F34A55; width: 100%; height: 50px; margin-bottom: -50px; ...

  10. BigDecimal比较2个值是否相等,不能用equals,而要用compareTo

    BigDecimal比较相等,不能用equals,要用compareTo