xml 实现圆形图 和 椭圆形图

时间:2023-03-09 06:46:41
xml 实现圆形图 和 椭圆形图

1. 效果图

xml 实现圆形图 和 椭圆形图

2.圆形图

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@drawable/bg_btn_round" />

bg_btn_round.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" > <solid android:color="@android:color/white" /> <size
android:height="30dp"
android:width="30dp" />
<stroke android:width="1dp"
android:color="@color/grey"/> </shape>

2. 椭圆形图

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@drawable/bg_btn_oval_gray" />

bg_btn_oval_gray.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:topLeftRadius="15dp"
android:topRightRadius="15dp"
android:bottomRightRadius="15dp"
android:bottomLeftRadius="15dp"/>
<solid android:color="@color/bg_btn_oval_gray" /> <size
android:height="30dp"
android:width="80dp" />
<stroke android:width="1dp"
android:color="@color/grey"/> </shape>

3. 实现蓝色效果,把<solid>的颜色改为蓝色就可以了

相关文章