【问题标题】:Add number in circle within text in textview在文本视图中的文本内添加圆圈中的数字
【发布时间】:2019-02-06 14:44:31
【问题描述】:

The number 4 circle

正如您在图片中看到的,文本中的圆圈中有数字“4”,并且它具有背景颜色。当您单击它会在浏览器中打开一个链接时,它可以作为参考。是否可以使用 spannable 或任何其他方式在 textview 中完成某些操作?

【问题讨论】:

标签: java android xml textview


【解决方案1】:

您可以使用 Drawable 来实现。

只需在 Drawable 中创建 background.xml

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

    <solid
        android:color="@color/colorAccent"/>
</shape>

并在 TextView 中应用背景,

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/background"
    android:gravity="center"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="14dp"
    android:paddingBottom="14dp"
    android:text="04"

它会产生这样的结果,

【讨论】:

  • 我希望它在其他文本中完成。请再次检查图像。左边有文字,右边数字4在文字之外。
猜你喜欢
  • 2019-11-07
  • 1970-01-01
  • 2017-04-16
  • 2012-11-16
  • 1970-01-01
  • 2023-03-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多