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.
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.
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))
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With