简体   繁体   中英

android how to make inner view circle shape as shown in Picture

i want to achieve the following shape with circle background, i have tried but my inner view is not getting in circle shape in Relative layout i will post my screen shot .

在此处输入图片说明

and I am getting the following Result with the layout i cerated 在此处输入图片说明

    <RelativeLayout
        android:id="@+id/circle_layout"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/whitecircle" >

        <RelativeLayout
            android:id="@+id/circle_layoutinner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/rating_viewtv"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:background="@drawable/circletwo" >

            <TextView
                android:id="@+id/ratingcup_viewtv_fonts"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:text="Y"
                android:textColor="@android:color/holo_purple" />
        </RelativeLayout>

        <TextView
            android:id="@+id/rating_viewtv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="3dp"
            android:text="4.5"
            android:textColor="@android:color/holo_purple" />
    </RelativeLayout>

</RelativeLayout>

my whitecircle.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadius="0dp"
    android:shape="ring"
    android:thicknessRatio="2"
    android:useLevel="false">

    <solid android:color="@color/white" />

</shape>

my circletwo.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadius="0dp"
    android:shape="ring"
    android:thicknessRatio="2"
    android:useLevel="false">

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

</shape>

try this.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/circle_layout"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:background="@drawable/circletwo" >

    <RelativeLayout
        android:id="@+id/circle_layoutinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/rating_viewtv"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" >

        <TextView
            android:id="@+id/ratingcup_viewtv_fonts"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="Y"
            android:textColor="#ff0000" />
    </RelativeLayout>

    <TextView
        android:id="@+id/rating_viewtv"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:background="#ffffff"
        android:gravity="center"
        android:text="4.5"
        android:textColor="#ff0000" />

</RelativeLayout>

try this too using linear layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/circle_layout"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:background="@drawable/circletwo"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/ratingcup_viewtv_fonts"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="2.2"
        android:text="Y"
        android:layout_gravity="center"
        android:gravity="center_vertical"
        android:textColor="#ff0000" />

    <TextView
        android:id="@+id/rating_viewtv"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.8"
        android:background="#ffffff"
        android:gravity="center"
        android:text="4.5"
        android:textColor="#ff0000" />


    </LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM