Android studio xml 的属性

虚线

属性属性值作用
shapeline设置形状为线型
stroke以下属性设置line的属性
widthinteger线的厚度
colorcolor线的颜色
dashGapinteger每段线的间隔(为0的话就是直线)
dashWidthinteger每段线的长度

代码如下:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">
    <!--android:width虚线的高度-->
    <!--android:width的值必须要小于用它做背景的View的height-->
    <stroke
        android:width="1dp"
        android:color="#f00"
        android:dashGap="2sp"

        android:dashWidth="10dp" />
</shape>

椭圆边框

属性属性值描述
shapeoval椭圆
stroke设置边框属性在这里插入图片描述
corners角度设置四个角的角度

代码如下:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <stroke
        android:width="2dp"
        android:color="#49da2b"
        android:dashGap="20sp"
        android:dashWidth="18dp" />
    <corners android:radius="10dp"/>
</shape>

环 ring

属性属性值描述
shapering
innerRadiusRatiofloat环内径比(屏幕宽度/半径)
thicknessRatiofloat厚度比(屏幕宽度/厚度)
typesweep渐变
在这里插入图片描述

代码如下:

<?xml version="1.0" encoding="utf-8"?><!--android:useLevel该值设为false,否则会看不到圆环画面-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadiusRatio="4"
    android:shape="ring"
    android:thicknessRatio="4"
    android:useLevel="false">
    <gradient
        android:endColor="#cbd5e1"
        android:startColor="#5adece"
        android:type="sweep" />
</shape>

<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:insetLeft="1.0px"
    android:insetRight="1.0px">
    <selector>
        <item>
            <shape android:shape="rectangle">
                <gradient
                    android:angle="270"
                    android:endColor="#154d91"
                    android:startColor="#24b124" />
                <corners android:radius="10dp" />
                <stroke
                    android:width="5dp"
                    android:color="#0f0" />

            </shape>
        </item>
    </selector>
</inset>

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值