TextView anchor link space

前端 未结 2 995
时光取名叫无心
时光取名叫无心 2021-01-18 07:42

I want to make a TextView with a link. I made it with combination of html and bit of java:

// used to enable link navigation on TextView
setMovementMethod(Li         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-18 08:07

    Use CDATA in string to use HTML tags and use Html.fromHtml() method to set the text.

    Implementation below:

    Set the text using Html.fromHtml() in your Activity class.

    TextView textView = (TextView) findViewById(R.id.textView);
    textView.setText(Html.fromHtml(getString(R.string.link)));
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    

    In strings.xml modify as below:

    Test link]]>
    

提交回复
热议问题