android shape不可用_Android中shape属性详解

在开发中经常会用到shape标签来定义控件的背景,shape标签总共有四个图形选项,分别是rectangle(矩形),oval(椭圆),line(横线)和ring(圆环) 。

不设置默认rectangle(矩形)

相关属性:

android:innerRadius 尺寸,内环的半径。

android:innerRadiusRatio 浮点型,以环的宽度比率来表示内环的半径,

android:thickness 尺寸,环的厚度

android:thicknessRatio 浮点型,以环的宽度比率来表示环的厚度,例如,如果android:thicknessRatio="2",

android:useLevel boolean值,如果当做是LevelListDrawable使用时值为true,否则为false.

下面的属性只有在android:shape="ring"时可用,其他的属性。

示例如下:

创建 drawable-》New-》Drawable resource file 资源文件

android:shape="ring"

android:innerRadius="100dp"

android:thickness="10dp"

android:useLevel="false">

效果图.jpg

二、基本属性

基本属性(corners、gradient、padding、size、solid、stroke)

1、corners(角)

android:radius="dimension" 全部的圆角半径

android:bottomLeftRadius="dimension" 左下角的圆角半径

android:bottomRightRadius="dimension" 右下角的圆角半径

android:topLeftRadius="dimension" 左上角的圆角半径

android:topRightRadius="dimension" 右上角的圆角半径

示例如下:

android:bottomLeftRadius="12dp"

android:bottomRightRadius="16dp"

android:radius="20dp"

android:topLeftRadius="4dp"

android:topRightRadius="8dp" />

效果图.jpg

2、solid(用以指定内部填充色)

只有一个属性

android:color="color" 指定填充的颜色

上个示例中有体现

3、gradient(用以定义渐变色,可以定义两色渐变和三色渐变,及渐变样式)

它的属性有下面几个:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值