Search code examples
androidandroid-layoutandroid-imageviewtextviewandroid-drawable

Circular Textview with bottom rectangle


I'm trying to create a circular text-view with a rectangle at bottom for reference purpose here I'm sharing the Sample image and code what I'm trying to achieve

Can anyone help me in create this following screen shot, Thanks in advance.

Trying to create this kind of circular text-view


Solution

  • Try this

       <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ff0"
        android:orientation="vertical">
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
    
            <TextView
                android:id="@+id/myTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="@drawable/ic_dot"
                android:gravity="center"
                android:padding="10dp"
                android:text="sdsjhdsd"
                android:textColor="#ff00" />
    
            <TextView
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/myTv"
                android:gravity="center"
                android:layout_centerHorizontal="true"
                android:background="@drawable/test"
                android:text="sdsjhdsd" />
        </RelativeLayout>
    </LinearLayout>
    

    android:background="@drawable/ic_dot"

       <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <corners
            android:bottomLeftRadius="100dp"
            android:bottomRightRadius="100dp"
            android:topLeftRadius="100dp"
            android:topRightRadius="100dp" />
        <solid android:color="@color/lightWhite" />
        <size
            android:width="100dp"
            android:height="100dp" />
        <stroke
            android:width="3dp"
            android:color="#22ff00" />
    </shape>
    

    android:background="@drawable/test"

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" >
        <solid android:color="#e60707" />
    
        <corners android:radius="50dp" />
    </shape>
    

    RESULT

    ![enter image description here