Can you make the text underlined in the Android layout?

Asked 2 years ago, Updated 2 years ago, 75 views

Can you make xml underline the text in the file?

android-layout android font

2022-09-22 22:28

1 Answers

Yes, String resource xml supports the same HTML.

<resource>
    <string name="your_string_here">This is an <u>underline</u>.</string>
</resources>

If you do the content in this way, there is an underline in the part that corresponds to the content.

Also, on the code,

TextView textView = (TextView) view.findViewById(R.id.textview);
SpannableString content = new SpannableString("Content");
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
textView.setText(content);

You can do it like this.


2022-09-22 22:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.