0

I would like to have an indent or 2 spaces after the bullet. However, when I add &nbsp ; I still see the underline. And I wonder if there is not a better way to solve this? Also, when looking at the bullet, it is missing some pixels on the left side. Is this normal?

Solution must also work till API 18.

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val someText = findViewById<TextView>(R.id.someTextView)
    val url = "<ul><li><a href='https://www.google.nl'>&nbsp;&nbsp;Awesome clickable link</a></li></ul>"
    setEditText(someText, url)
}

fun setEditText(textView: TextView, text: String) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        textView.text = Html.fromHtml(text, Html.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE)
    } else {
        textView.text = Html.fromHtml(text)
    }
    textView.movementMethod = LinkMovementMethod.getInstance()
}

activity_main.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="16dp">

    <TextView
        android:id="@+id/someTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

enter image description here

This solution does not work because I am getting html tags .

Jim Clermonts
  • 1,694
  • 8
  • 39
  • 94
  • What do you mean exactly with: "when looking at the bullet, it is missing some pixels on the left side. Is this normal?" Should it be left aligned as the blue Box? – k.vincent Apr 19 '18 at 14:39

1 Answers1

0

Add margin-left to your <a href... element and also a property display:block and force all with !important and remove &nbsp;:

...
val url = "<ul><li><a href='https://www.google.nl' style='display:block !important; margin-left:30px !important;'>Awesome clickable link</a></li></ul>"
...
k.vincent
  • 3,743
  • 8
  • 37
  • 74