形状图形(shape)
16lz
2021-12-04
shape 常用属性
android:shape="rectangle" 矩形,默认值
android:shape="oval" 椭圆,此时corners (圆角节点)失效
android:shape="line" 直线,必须设置stroke(描边)节点
android:shape="ring" 圆环
下面定义了6种图形
-
corners (圆角)
android:radius="20dp" 直接定义4个圆角
android:bottomLeftRadius="20dp" 左下角
android:bottomRightRadius="20dp" 右下角
android:topLeftRadius="20dp" 左上角
android:topRightRadius="20dp" 右上角
<?xml version="1.0" encoding="utf-8"?>
image.png -
gradien(渐变)
android:angle ( 起始角度 0 -9点方向 90- 6点方向 180 -3点方向 270 12点方向)
android:type (linear 线性渐变 默认值 , radial 放射渐变 起始颜色是圆心, sweep 滚动渐变)
android:centerY="0.4" 圆心y坐标
<?xml version="1.0" encoding="utf-8"?>
image.png -
padding (定义内容离边界的距离)
-
solid(填充颜色,背景色)
-
size(尺寸)
无节点表示宽高自适应
-
stroke(描边)
android:dashGap="@dimen/len_4" 每段虚线之间的间隔
android:dashWidth="@dimen/len_4" 每段虚线之间的宽度
上面2个同时存在才为虚线
android:width="@dimen/len_4" 描边厚度
<?xml version="1.0" encoding="utf-8"?>
image.png <?xml version="1.0" encoding="utf-8"?>
v21 涟漪效果
<?xml version="1.0" encoding="utf-8"?> -
v21 以上 v21 以下 -
进阶
点击背景 实现变色
<?xml version="1.0" encoding="utf-8"?> -
-
更多相关文章
- Android帧布局-实现渐变效果
- Drawable
- android中自定义shape
- Android(安卓)背景渐变 渐变背景 shape
- Android中自定义shape
- Android(安卓)Drawable Resources系列10:
- android之shape
- Android中的Shape使用总结
- android shape控件的使用