How do I make a link within string resource to be clickable and open a web page when the user clicks it?
<string name="about" translatable="false">
Click <annotation font="lato_bold">.
<a href="https://google.com/">here</a></annotation>
for more information
</string>
I could do this with TextView
but I don't know how to do it with string resources.
Thank You.
CodePudding user response:
Change
<string name="about" translatable="false">
Click <annotation font="lato_bold">.
<a href="https://google.com/">here</a></annotation>
for more information
</string>
to
<string name="about">
<a href="https://google.com/">here</a>
</string>
You can directly use anchor tag
inside string tag
CodePudding user response:
You can do it from coding:
Kotlin:
var result:Textview = findViewById(R.id.myTextview)
result!!.movementMethod = LinkMovementMethod.getInstance()
val text = "<a href='http://www.google.com'>Google.com</a>"
result!!.text = Html.fromHtml(text)