android shape常用形状,代替drawable资源节省空间

1.实心长方形
在这里插入图片描述

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <!-- 设置固定填充色 -->
    <solid android:color="#f00" />

    <size android:width="60dp" android:height="30dp"/>

</shape>

2.长方形外框
在这里插入图片描述

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

    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置描边 -->
    <stroke android:width="2dp" android:color="#f00" ></stroke>

</shape>

3.虚线长方形外框

在这里插入图片描述

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置描边 -->
    <stroke android:width="2dp" android:color="#f00" android:dashWidth="5dp" android:dashGap="5dp"></stroke>
</shape>

4.虚线椭圆形
在这里插入图片描述

    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置描边 -->
    <stroke android:width="2dp" android:color="#f00" android:dashWidth="5dp" android:dashGap="5dp"></stroke>

    <corners android:radius="15dp"/>
	</shape>

5.实心椭圆形

在这里插入图片描述

	<shape xmlns:android="http://schemas.android.com/apk/res/android" >
	    <!-- 设置固定填充色 -->
	    <solid android:color="#f00" />
	
	    <size android:width="60dp" android:height="30dp"/>
	
	    <corners android:radius="10dp"/>
	
	</shape>

6.椭圆形外框
在这里插入图片描述

	<shape xmlns:android="http://schemas.android.com/apk/res/android" >
	
	    <size android:width="60dp" android:height="30dp"/>
	    <!-- 设置描边 -->
	    <stroke android:width="2dp" android:color="#f00" ></stroke>
	
	    <corners android:radius="15dp"/>
	</shape>

7.圆形
在这里插入图片描述

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="20dp"
android:shape="ring"
android:thickness="2dp"
android:useLevel="false" >

<!-- 设置固定填充色 -->
<solid android:color="#f00" />

<size
    android:height="44dp"
    />

8.直线
在这里插入图片描述

    <stroke android:width="1dp" android:color="#f00"/>

    <size android:height="10dp"></size>
</shape>

9.虚线
在这里插入图片描述

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >

    <stroke
        android:dashGap="8px"
        android:dashWidth="8px"
        android:width="1dp"
        android:color="#f00" />

    <size android:height="30dip" />

</shape>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值