'How to set text to the imageview like gmail inbox?

I want to design enter image description here
like this. how to set first charecter to that circle and should circle be in random color.



Solution 1:[1]

TRY this Change color as per your requirement.

you will add colors programmatically.

and text add pragmatically using this link

Textview -

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/ic_baseline_circle_24"
        android:gravity="center"
        android:maxLength="1"
        android:padding="10dp"
        android:text="M"
        android:textColor="@android:color/white"
        android:textSize="12sp"
        android:textStyle="normal" />

add in res/drawable/ic_baseline_circle_24.xml

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:tint="#41B582"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <path
        android:fillColor="@android:color/white"
        android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2z" />
</vector>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sandesh KhutalSaheb