Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to underline text in Android Studio?

Tags:

android

Looked everywhere, couldnt find a solution for this. Setting bold or italic is very easy, why is setting underline not as easy?

Here's my bit of relevant code:

   <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/forgotpasswordHolder"
        android:layout_marginTop="10dp">

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Forgot your password?"
            android:id="@+id/labForgotpassword"
            android:textColor="#6BB08C"
            android:layout_weight="1"
            android:textStyle="bold|italic"
            android:layout_gravity="left"
            android:paddingLeft="20dp"
            android:textIsSelectable="true"
            android:singleLine="false" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Not a member?"
            android:id="@+id/signup"
            android:textColor="#6BB08C"
            android:layout_weight="1"
            android:textStyle="bold|italic"
            android:singleLine="false"
            android:layout_gravity="right"
            android:gravity="right"
            android:paddingRight="20dp"
            android:textIsSelectable="true" />
    </LinearLayout>

I have two "Forgot your password? and a "Not a member?" buttons, and I'd love it if I could underline the text(s).

Thanks in advance!

like image 267
Mike K Avatar asked Jan 08 '23 12:01

Mike K


1 Answers

Use a string resource with <u> tags, like this

android:text="@string/forgotPassword"

Then in strings.xml, create a String

<string name="forgotPassword"><u>Forgot your password?</u></string>
like image 194
Andrew Brooke Avatar answered Jan 25 '23 19:01

Andrew Brooke