android阴影分割线,android shape的使用及渐变色、分割线、边框、半透明阴影

shape使用、渐变色、分割线、边框、半透明、半透明阴影效果。

首先简单了解一下shape中常见的属性。(详细介绍参看 api文档)

xmlns:android="http://schemas.android.com/apk/res/android"

android:shape=["rectangle" | "oval" | "line" | "ring"] > --- 默认为rectangle

android:radius="integer" -- 半径,会被下边的属性覆盖,默认为1dp,

android:topLeftRadius="integer"

android:topRightRadius="integer"

android:bottomLeftRadius="integer"

android:bottomRightRadius="integer" />

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"] />

android:left="integer"

android:top="integer"

android:right="integer"

android:bottom="integer" />

android:width="integer"

android:height="integer" />

android:color="color" />

android:width="integer"

android:color="color"

android:dashWidth="integer" -- 虚线宽度

android:dashGap="integer" /> -- 虚线间隔宽度

注意:

1、android:radius,半径,会被下边的单个角度半径属性覆盖,默认为1dp,

2、在使用时,如果单独设置四个角度,又大小不一致时,eclipse的graphics preview会报错。但是直接真机运行即可。(比如实线上边直角,下边屈角的效果)

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:

android:shape="rectangle">

android:startColor="#FFFF0000"

android:endColor="#80FF00FF"

android:angle="45"/>

android:top="7dp"

android:right="7dp"

android:bottom="7dp" />

如图:

8e501fe62d5581f795b874f20c67af07.png

2、白色边框、半透明效果

android:shape="rectangle" >

android:dashGap="0dp"

android:width="4dp"

android:color="@android:color/white" />

如图:

a2c13f38e663bacc4aef6b0bf8b2c8be.png   

6fe68eb36472e9863cbf2fd8f01aa6e8.png

3、分割线效果:

android:shape="line" >

android:width="4dp"

android:color="@android:color/black" />

如图:

d471f3c2d768302580f3c3cb96aae147.png

4、单边屈角效果

android:topLeftRadius="5dp"

android:topRightRadius="5dp"

android:bottomLeftRadius="30dp"

android:bottomRightRadius="30dp"/>

android:dashGap="0dp"

android:width="4dp"

android:color="@android:color/white" />

如图:

704acd67d7d391ef58e87cdaa8df4adf.png

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值