Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Show the Letter with the Circle Android

Tags:

android

I follow this solution to make a circular Imagen with the First letter (Such as Gmail Contacts)

but i don't know how visualize that image...

I'm use a EditText but it doesn't work.

Someone can help me.

like image 272
Fabian Stevens Varon Valencia Avatar asked Oct 04 '15 06:10

Fabian Stevens Varon Valencia


People also ask

How do you display a first letter of name in image layout if there is no image?

You should have a RelativeLayout where you have to place 2 View s: a TextView for a letter and an ImageView for an image(photo/avatar) which has to cover over the TextView completely. When there is no image in ImageView its transparent and thus you gonna see your TextView with the letter thru "image". Save this answer.


1 Answers

This link will surely solve your purpose and you will be able to understand the working too.

OR

You can simply do like this (only one color will be applied to all of the title/initial list backgrounds with this code but you can surely customize it):

circle.xml in the drawable folder of the project

<?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>

then in your layout(xml) code just add a TextView like this :

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

and then set the title TextView with initial element of the sentence or list like : title.setText(dataList.get(i).charAt(0)).

like image 189
Vipul Asri Avatar answered Sep 29 '22 03:09

Vipul Asri