Here I used clickable URL on Textview
and it works. But how can I set clickable and highlighted Text with Open URL with a browser. It's possible from Android XML OR kotlin without using java code like setText(Html.fromHtml(""))
.
String value = "<html>Visit Web <a href=\"http://www.domainname.com\">mysite</a> View</html>";
TextView text = (TextView) findViewById(R.id.text);
text.setText(Html.fromHtml(value));
text.setMovementMethod(LinkMovementMethod.getInstance());
<TextView
android:textSize="18sp"
android:autoLink="web"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="http://www.example.com"
tools:ignore="HardcodedText" />
It's No required declear layout id and no code from java side. it's works from xml
Use Autolink
android:autoLink="web"
android:autoLink="phone"
android:autoLink="email"
android:autoLink="web"
android:autoLink="all"