android shape的使用详解以及常用效果(渐变色、分割线、边框、半透明阴影效果等)...
shape使用、渐变色、分割线、边框、半透明、半透明阴影效果。
首先简单了解一下shape中常见的属性。(详细介绍参看 api文档 )
转载请注明:Rflyee_大飞: http://blog.csdn.net/rflyee/article/details/20785495
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape=["rectangle" | "oval" | "line" | "ring"] > --- 默认为rectangle<corners -- shape=“rectangle”时使用, android:radius="integer"-- 半径,会被下边的属性覆盖,默认为1dp,android:topLeftRadius="integer"android:topRightRadius="integer"android:bottomLeftRadius="integer"android:bottomRightRadius="integer" /><gradient -- 渐变android:angle="integer"android:centerX="integer"android:centerY="integer"android:centerColor="integer"android:endColor="color"android:gradientRadius="integer"android:startColor="color"android:type=["linear" | "radial" | "sweep"]android:useLevel=["true" | "false"] /><padding android:left="integer"android:top="integer"android:right="integer"android:bottom="integer" /><size -- 指定大小,一般用在imageview配合scaleType属性使用。大小一般会适配滴android:width="integer"android:height="integer" /><solid -- 填充颜色,可是是十六进制颜色。(比如想设置半透明效果,直接使用十六就只就OK)android:color="color" /><stroke -- 指定边框,border,dashWidth和dashGap有一个为0dp则为实线android:width="integer"android:color="color"android:dashWidth="integer" -- 虚线宽度android:dashGap="integer" /> -- 虚线间隔宽度 </shape>
ImageView
, you can restrict scaling by setting the android:scaleType
to "center"
举个栗子:
1、渐变色
res/drawable/gradient_box.xml
:
<?xml version="1.0" encoding="utf-8"?><shapexmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><gradientandroid:startColor="#FFFF0000"android:endColor="#80FF00FF"android:angle="45"/><paddingandroid:left="7dp"android:top="7dp"android:right="7dp"android:bottom="7dp"/><cornersandroid:radius="8dp"/></shape>
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle" ><corners android:radius="16dp" /><!-- 这是半透明,还可以设置全透明,那就是白色边框的效果了 --><solid android:color="#80065e8d" /><stroke android:dashGap="0dp"android:width="4dp"android:color="@android:color/white" /> </shape>
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="line" ><stroke android:width="4dp"android:color="@android:color/black" /> </shape>
<?xml version="1.0" encoding="utf-8"?> <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"><corners android:topLeftRadius="5dp"android:topRightRadius="5dp"android:bottomLeftRadius="30dp"android:bottomRightRadius="30dp"/><!-- 这是半透明,还可以设置全透明,那就是白色边框的效果了 --><solid android:color="#ff065e8d" /><stroke android:dashGap="0dp"android:width="4dp"android:color="@android:color/white" /></shape>
如图:
android shape的使用详解以及常用效果(渐变色、分割线、边框、半透明阴影效果等)
转载于:https://www.cnblogs.com/Free-Thinker/p/5556069.html
android shape的使用详解以及常用效果(渐变色、分割线、边框、半透明阴影效果等)...相关推荐
- android shape.xml 属性详解
转载源:http://blog.csdn.net/harvic880925/article/details/41850723 一.简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标 ...
- android常用技术网站收藏过的网址 给 Android 开发者的 RxJava 详解 Android设备标识-没有完美的解决方案-只有取舍 - 小彼得的专栏 - 博客频道 - CSDN.NET
收藏过的网址 http://www.jianshu.com/p/a7b36d682b6f?ref=myread Android插件化快速入门与实例解析 http://www.cnblogs.com/ ...
- ANDROID L——Material Design详解(视图和阴影)
转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! Android L: Google已经确认Android L就是Android Lolli ...
- Android应用坐标系统全面详解
Android应用坐标系统全面详解 原文链接:CSDN@工匠若水,http://blog.csdn.net/yanbober/article/details/50419117 1. 背景 去年有很多人 ...
- android ------- 开发者的 RxJava 详解
在正文开始之前的最后,放上 GitHub 链接和引入依赖的 gradle 代码: Github: https://github.com/ReactiveX/RxJava https://githu ...
- android layout_width 属性,android:layout_weight属性详解
在android开发中LinearLayout很常用,LinearLayout的内控件的android:layout_weight在某些场景显得非常重要,比如我们需要按比例显示.android并没用提 ...
- 宏锦软件 Android 的 ListView 使用详解
宏锦软件爱好者在开发Android软件时,对ListView的使用有点陌生,于是翻了许多资料,这里给大家一份比较好的教程,希望有用. 在android开发中ListView是比较常用的组件,它以 ...
- Android面试Hash原理详解二
Hash系列目录 Android面试Hash原理详解一 Android面试Hash原理详解二 Android面试Hash常见算法 Android面试Hash算法案例 Android面试Hash原理详解 ...
- Android 源码编译详解【合集篇】
Android 源码编译详解[一]:服务器硬件配置及机型推荐 做 Android系统开发多年,开发环境都是入职就搭建好了,入职时拿个账号密码就直接开始搞开发了,年初换了新公司,所有的项目都是刚起步,一 ...
- Android设备扫描机制详解
Android设备扫描机制详解 本文基于Android pie,对Android的设备扫描机制做一个全面的解析,由于本人掌握的知识有限,如有讲错的地方还请大家指出来. Android提供了一套扫描机制 ...
最新文章
- 模糊综合评价法用什么软件实现_基于建管养一体化模式的钢桥面铺装方案综合评价分析...
- 数据库分页和使用jstl标签替换分页的jsp代码
- 剧透LiveVideoStackCon 2020:除了干货,还有更多优惠的年度通票
- BMP位图之8位位图(三)
- php mysql 地理位置_PHP MySql和地理位置
- CTS(13)---CTS 测试之Media相关测试failed 小结(一)
- Python+tkinter模拟京东旋转图片式验证码输入
- Microsoft Visual Studio 语言切换
- c/c++教程 - 2.4.2.6 初始化列表语法,初始化列表参数
- 如何在 Mac 上更改特定应用程序的语言?
- 2.3,2.2,2.1最新谷歌服务包发布附下载(原创)
- 《TensorFlow技术解析与实战》——3.3 可视化的例子
- 推荐3个计算机专业的英文电子书下载网站
- 基于ANSYS WORKBENCH的装配体分析
- 因忘记一个约会而写的致歉函
- 非结构化数据的存储与查询
- VS下报LNK1104的一种解决方法
- 如何使用JavaScript检查数字是否为素数?
- 可视化工具VisIt安装使用教程(Windows)
- 微信小程序通过getphonenumber 获取电话号码无法获取code值