Search code examples
androidtextviewrounded-corners

I would like to create a textView surrounded rounded circle the diagram as shown below


I would like to create a textView surrounded rounded circle the diagram as shown below:

Image Link :- https://i.sstatic.net/E0cMB.png

Can anyone of you let me know how to do this?


Solution

  • Check this how to implement the above image requirement. Your Layout data should be like this:

    <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#004473">
    
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="60dp"
                    android:layout_margin="5dp"
                    android:background="@drawable/linear_layout_corner_shape"
                    android:orientation="horizontal">
    
                    <TextView
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:gravity="center"
                        android:text="01"
                        android:background="@drawable/textview_circle_shape"
                        android:textSize="20sp"
                        android:textColor="#000000"/>
    
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center_vertical"
                        android:paddingLeft="15dp"
                        android:text="Lorum Ipusum"
                        android:textSize="20sp"
                        android:textColor="#FFFFFF"/>
    
                </LinearLayout>
    
            </LinearLayout>
    

    Drawable files data:

    linear_layout_corner_shape.xml

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    
    <solid android:color="#004473"></solid>
    
    <stroke
        android:width="2dp"
        android:color="#FFFFFF"></stroke>
    
    <corners android:radius="30dp"></corners>
    

    textview_circle_shape.xml

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    
    <solid android:color="#FFFFFF"></solid>