How can i create a circle which has a number in?

前端 未结 2 1394
青春惊慌失措
青春惊慌失措 2020-12-30 04:47

I\'m programming an Android game using AndEngine. I want to create a circle which has a number in, like in this picture:

相关标签:
2条回答
  • 2020-12-30 05:27

    Something like this:

    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>
    

    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>
    

    looks like this:

    enter image description here

    0 讨论(0)
  • 2020-12-30 05:51

    Well I guess the simplest way is to just put a picture like that in haha. You could always use an image with a circle then layer the text with the number over the top of it.

    0 讨论(0)
提交回复
热议问题