I am new in android programming.I am developing a simple app . 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 xml code:
<Button
android:id="@+id/park"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/park"
android:text="@string/button_name"
android:background="#00000000"
android:textColor="#000000"/>
And the string file has:
<resources>
<string name="button_name"><u>parking areas</u></string>
</resources
This approa ch works in textview but not in button.
-any suggestion?
This should make your ButtonText bold, underlined and italic at the same time.
strings.xml
To set this String to your TextView, do this in your main.xml
Code only
Java:
Kotlin:
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
: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
Java:
Kotlin:
Use this:
You can't set underline from xml file. To set underline using code you need to set the underline flag on button.