我有一个TextView,我想通过XML在我的文本中添加一个子弹符号。这可能吗?


当前回答

使用Unicode我们可以很容易地做到这一点,但如果想改变子弹的颜色,我尝试了彩色子弹图像,并将其设置为drawableStart,它工作

<TextView     
    android:text="Hello bullet"
    android:drawableStart="@drawable/bulleticon" >
</TextView>

其他回答

您必须使用正确的字符编码来实现此效果。你可以试试&#8226;

更新

Just to clarify: use `setText("\u2022 Bullet");` to add the bullet programmatically. `0x2022 = 8226`

由于android不支持<ol>, <ul>或<li> html元素,我必须这样做

<string name="names"><![CDATA[<p><h2>List of Names:</h2></p><p>&#8226;name1<br />&#8226;name2<br /></p>]]></string>

如果你想保持自定义空间,那么使用</pre>标签

这招对我很管用:

<string name="text_with_bullet">Text with a \u2022</string>

复制粘贴:我还用过其他一些奇怪的文字,比如“京城”和“►”。

编辑:这里有一个例子。最下面的两个按钮分别是“text=”和“►”。

使用Unicode我们可以很容易地做到这一点,但如果想改变子弹的颜色,我尝试了彩色子弹图像,并将其设置为drawableStart,它工作

<TextView     
    android:text="Hello bullet"
    android:drawableStart="@drawable/bulleticon" >
</TextView>