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>
注意:
<corners>
1、 android:radius,半 径,会被下边的单个角度半径属性覆盖,默认为1dp,
2、在使用时,如果单独设置四个角度,又大小不一致时,eclipse的graphics preview会报错。但是直接真机运行即可。(比如实线上边直角,下边屈角的效果)
<size>
Note:  The shape scales to the size of the container View proportionate to the dimensions defined here, by default. When you use the shape in an  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>
如图:
2、白色边框、半透明效果
<?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>
如图:
3、分割线效果:
<?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>

如果:
4、单边屈角效果
<?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>

如图:

另:附上一份颜色进制图,需要的可以查阅:http://blog.sina.com.cn/s/blog_684a1d160100umuq.html
转载请注明:Rflyee_大飞: http://blog.csdn.net/rflyee/article/details/20785495

android shape的使用详解以及常用效果(渐变色、分割线、边框、半透明阴影效果等)

转载于:https://www.cnblogs.com/Free-Thinker/p/5556069.html

android shape的使用详解以及常用效果(渐变色、分割线、边框、半透明阴影效果等)...相关推荐

  1. android shape.xml 属性详解

    转载源:http://blog.csdn.net/harvic880925/article/details/41850723 一.简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标 ...

  2. android常用技术网站收藏过的网址 给 Android 开发者的 RxJava 详解 Android设备标识-没有完美的解决方案-只有取舍 - 小彼得的专栏 - 博客频道 - CSDN.NET

    收藏过的网址 http://www.jianshu.com/p/a7b36d682b6f?ref=myread  Android插件化快速入门与实例解析 http://www.cnblogs.com/ ...

  3. ANDROID L——Material Design详解(视图和阴影)

    转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! Android L: Google已经确认Android L就是Android Lolli ...

  4. Android应用坐标系统全面详解

    Android应用坐标系统全面详解 原文链接:CSDN@工匠若水,http://blog.csdn.net/yanbober/article/details/50419117 1. 背景 去年有很多人 ...

  5. android ------- 开发者的 RxJava 详解

    在正文开始之前的最后,放上 GitHub 链接和引入依赖的 gradle 代码: Github:  https://github.com/ReactiveX/RxJava  https://githu ...

  6. android layout_width 属性,android:layout_weight属性详解

    在android开发中LinearLayout很常用,LinearLayout的内控件的android:layout_weight在某些场景显得非常重要,比如我们需要按比例显示.android并没用提 ...

  7. 宏锦软件 Android 的 ListView 使用详解

     宏锦软件爱好者在开发Android软件时,对ListView的使用有点陌生,于是翻了许多资料,这里给大家一份比较好的教程,希望有用. 在android开发中ListView是比较常用的组件,它以 ...

  8. Android面试Hash原理详解二

    Hash系列目录 Android面试Hash原理详解一 Android面试Hash原理详解二 Android面试Hash常见算法 Android面试Hash算法案例 Android面试Hash原理详解 ...

  9. Android 源码编译详解【合集篇】

    Android 源码编译详解[一]:服务器硬件配置及机型推荐 做 Android系统开发多年,开发环境都是入职就搭建好了,入职时拿个账号密码就直接开始搞开发了,年初换了新公司,所有的项目都是刚起步,一 ...

  10. Android设备扫描机制详解

    Android设备扫描机制详解 本文基于Android pie,对Android的设备扫描机制做一个全面的解析,由于本人掌握的知识有限,如有讲错的地方还请大家指出来. Android提供了一套扫描机制 ...

最新文章

  1. 模糊综合评价法用什么软件实现_基于建管养一体化模式的钢桥面铺装方案综合评价分析...
  2. 数据库分页和使用jstl标签替换分页的jsp代码
  3. 剧透LiveVideoStackCon 2020:除了干货,还有更多优惠的年度通票
  4. BMP位图之8位位图(三)
  5. php mysql 地理位置_PHP MySql和地理位置
  6. CTS(13)---CTS 测试之Media相关测试failed 小结(一)
  7. Python+tkinter模拟京东旋转图片式验证码输入
  8. Microsoft Visual Studio 语言切换
  9. c/c++教程 - 2.4.2.6 初始化列表语法,初始化列表参数
  10. 如何在 Mac 上更改特定应用程序的语言?
  11. 2.3,2.2,2.1最新谷歌服务包发布附下载(原创)
  12. 《TensorFlow技术解析与实战》——3.3 可视化的例子
  13. 推荐3个计算机专业的英文电子书下载网站
  14. 基于ANSYS WORKBENCH的装配体分析
  15. 因忘记一个约会而写的致歉函
  16. 非结构化数据的存储与查询
  17. VS下报LNK1104的一种解决方法
  18. 如何使用JavaScript检查数字是否为素数?
  19. 可视化工具VisIt安装使用教程(Windows)
  20. 微信小程序通过getphonenumber 获取电话号码无法获取code值

热门文章

  1. 单身狗应该怎么过七夕节?
  2. linux等 入门思维导图
  3. 使用js切割URL的参数
  4. 强化学习读书笔记 - 03 - 有限马尔科夫决策过程
  5. vs中debug和release版本的区别(转)
  6. javascript 数组去重 unique
  7. 回忆大学到现在为止学到了什么?
  8. 防止电子眼拍到车牌的秘籍
  9. the basic concepts of c#
  10. 解决IE8在vs2005下不能调试的问题.