Home » Android » linkify – Android LinkMovementMethod in XML?

linkify – Android LinkMovementMethod in XML?

Posted by: admin June 15, 2020 Leave a comment

Questions:

To enable Linkify behavior, I do this in code:

textView.setMovementMethod(LinkMovementMethod.getInstance());

Is there a way to set this in the layout xml for the textview?

How to&Answers:

No, there is not. If you are using setMovementMethod(LinkMovementMethod.getInstance()); in so many places in your app that you want to avoid it, you should consider creating and using a custom class extending TextView which executes that method.

Answer:

Use the “autoLink” property in the XML layout