0

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 .

enter image description here

and I am getting the following Result with the layout i cerated enter image description here

    <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>
M S Gadag
  • 2,057
  • 1
  • 12
  • 15
Achin
  • 1,252
  • 4
  • 28
  • 63
  • http://stackoverflow.com/a/14106539/1576416 this link might help you to move ahead and achieve your requirement. – Amrut Bidri Jan 15 '15 at 05:05
  • hi thanku for your reply , but is it possible with my current logic that i have posted my layout above ? – Achin Jan 15 '15 at 05:08
  • you can draw only white circle with layout xml but not orange. so draw your shape on canvas and convert it to bitmap. and use that bitmap wherever you want. – Amrut Bidri Jan 15 '15 at 05:11

1 Answers1

1

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>
M S Gadag
  • 2,057
  • 1
  • 12
  • 15