I have a button which is transparent and has an icon and text.
I want to underline the text of the button but i have not been able to do this.
Below is my
Code only
Java:
Button button = (Button) findViewById(R.id.park);
button.setPaintFlags(button.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
Kotlin:
val button = findViewById
Resource string with static text (xml only)
If you have a static text in your resources you could also use the following approach in your strings.xml
:
I\'m underlined
Resource string with dynamic text (xml + code)
If you're using dynamic text but don't like the first approach (which isn't the best imho either), you could also use following:
strings.xml
%s
Java:
button.setText(getString(R.string.underlined_dynamic_text, "I'm underlined");
Kotlin:
button.text = getString(R.string.underlined_dynamic_text, "I'm underlined")