美文网首页
Android shape 圆环的三种实现

Android shape 圆环的三种实现

作者: 懵懵懂懂_YOYO | 来源:发表于2022-06-21 10:25 被阅读0次

自定义 背景时,常用到 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>

相关文章

网友评论

      本文标题:Android shape 圆环的三种实现

      本文链接:https://www.haomeiwen.com/subject/censvrtx.html