Android shape 圆环的三种实现

2022-06-21  本文已影响0人  懵懵懂懂_YOYO

自定义 背景时,常用到 shape 的方法


image.png

方法一

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadiusRatio="3"
    android:shape="ring"
    android:thicknessRatio="8"
    android:useLevel="false">
    <gradient
        android:centerColor="#ff0000"
        android:endColor="#0ff676"
        android:startColor="#B23AEE"
        android:useLevel="false" />
</shape>

方法二

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false">
    <stroke
        android:width="2dp"
        android:color="#ff0000" />
    <size
        android:width="20dp"
        android:height="20dp" />
</shape>

方法三

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadius="100dp"
    android:shape="ring"
    android:thickness="10dp"
    android:useLevel="false">
    <stroke
        android:width="10dp"
        android:color="#ff6652" />
  
</shape>
上一篇 下一篇

猜你喜欢

热点阅读