0

I want to create a button which should be like the sample image. Circular Image View with overlapping text ( Clickable ).I have tried some libraries but none of them offer android:text="something" function.

Is there any library that offers them both together?

  <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="3dp"
                android:paddingBottom="5dp"
                android:paddingTop="5dp">
  <LinearLayout
                    android:id="@+id/layout2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/layout1"
                    android:gravity="center"
                    android:orientation="horizontal"
                    android:padding="2dp"
                    android:paddingLeft="10dp">
  <de.hdodenhof.circleimageview.CircleImageView
                        xmlns:app="http://schemas.android.com/apk/res-auto"
                        android:id="@+id/profile_image"
                        android:layout_width="96dp"
                        android:layout_height="96dp"
                        android:src="@drawable/tem_hashtag_bn_04"
                        app:civ_border_width="1dp"
                        app:civ_border_color="#FF000000"/>
</LinearLayout>
  </RelativeLayout>

Click able Circular Image View

Click able Circular Image View

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Ananna Rahman
  • 165
  • 1
  • 10
  • @NileshRathod, Did it by mistake. btw please help me with another question https://stackoverflow.com/q/52534880/10323427?sem=2 – Ananna Rahman Sep 27 '18 at 11:11

3 Answers3

1

try this

<FrameLayout
        android:id="@+id/speaker_avatar_container"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_gravity="center_vertical">

        <TextView
            android:id="@+id/placeholder"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:gravity="center"
            android:background="@drawable/circle"
            android:textColor="@color/white"/>

        <CircleImageView
            android:id="@+id/avatar"
            android:layout_width="40dp"
            android:layout_height="40dp" />
    </FrameLayout>

and create a circle.xml and paste

    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="20dp" />
    <solid android:color="@color/grey" />
    <size
        android:width="40dp"
        android:height="40dp" />
</shape>  

I got this answer from enter link description here

Kevin Kurien
  • 812
  • 6
  • 14
1

The solution from Nilesh Rathod worked out well, just modified a bit for my requirements.

solved.

Code:

<RelativeLayout

                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/layout1"
                        android:gravity="center"
                        android:orientation="horizontal"
                        android:padding="2dp"

                        android:paddingLeft="10dp">

                        <de.hdodenhof.circleimageview.CircleImageView
                            xmlns:app="http://schemas.android.com/apk/res-auto"
                            android:id="@+id/profile_image1"
                            android:layout_width="96dp"
                            android:layout_height="96dp"
                            android:src="@drawable/tem_hashtag_bn_04"
                            app:civ_border_width="1dp"
                            app:civ_border_color="#FF000000"/>
                        <TextView

                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignBottom="@id/profile_image1"
                            android:layout_alignLeft="@id/profile_image1"
                            android:layout_alignRight="@id/profile_image1"
                            android:layout_alignTop="@id/profile_image1"
                            android:layout_gravity="center"
                            android:gravity="center"
                            android:padding="10dp"
                            android:textStyle="bold"
                            android:textColor="@color/colorWhite"
                            android:text="100%" />
                    </RelativeLayout>**strong text**
halfer
  • 19,824
  • 17
  • 99
  • 186
Ananna Rahman
  • 165
  • 1
  • 10
0

Try this

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <de.hdodenhof.circleimageview.CircleImageView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/myCircleImageView"
        android:layout_width="96dp"
        android:layout_height="96dp"
        android:src="@color/colorPrimary"
        app:civ_border_width="2dp"
        app:civ_border_color="#FF000000"/>


    <TextView
        android:id="@+id/cmll_completed_per"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@id/myCircleImageView"
        android:layout_alignLeft="@id/myCircleImageView"
        android:layout_alignRight="@id/myCircleImageView"
        android:layout_alignTop="@id/myCircleImageView"
        android:layout_gravity="center"
        android:gravity="center"
        android:padding="10dp"
        android:textStyle="bold"
        android:textColor="@android:color/white"
        android:text="100%" />

</RelativeLayout>

OUTPUT

enter image description here

AskNilesh
  • 67,701
  • 16
  • 123
  • 163