最佳答案
这link一定会解决您的目的,您也将能够理解工作。
或
你可以简单地这样做(只有一种颜色将被应用到所有的标题/初始列表背景使用这段代码,但你当然可以自定义它):
circle.xml在工程的drawable文件夹下
<?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))
。
关于android - Android如何用圆圈显示字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32930636/