How to show a letter with an Android circle

I follow this decision to make a circular Imagen with the first letter (e.g. with Gmail contacts)

but I don’t know how to render this image ...

I use EditText, but it does not work.

Someone can help me.

+4
source share
1 answer

This link will certainly solve your goal, and you too will be able to understand the work.

OR

you can do it simply (only one color will be applied to the whole font of the header / source list with this code, but you can customize it):

circle.xml in the selected project folder

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="oval">
        <solid android:color="@color/color_accent" />
</shape>

(xml) TextView, :

<TextView
    android:id="@+id/title"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/circle"
    android:gravity="center_vertical" />

title TextView , : title.setText(dataList.get(i).charAt(0)).

+15

Source: https://habr.com/ru/post/1610140/


All Articles