且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何创建一个有数字的圆圈?

更新时间:2021-11-25 22:54:47

是这样的:

circle.xml(在 res/drawable 中)

circle.xml (in res/drawable)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >

    <solid android:color="#aaf" />

</shape>

和 circletext.xml(在资源/布局中):

and circletext.xml (in res/layout):

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:orientation="vertical" >

    <TextView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_gravity="center"
        android:background="@drawable/circle"
        android:gravity="center"
        android:shadowColor="@android:color/white"
        android:shadowRadius="10.0"
        android:text="4"
        android:textColor="@android:color/black"
        android:textSize="18sp" />

</FrameLayout>

看起来像这样: