1

I am a beginner in Android Programming. I was creating an app and I want to underline a text. Please have a look into my code snippet

<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical">
    <TextView
        android:layout_width="wrap_content"
        android:text="hello world"
        android:id="@+id/textview"
        android:layout_height="wrap_content"
         />
    <View
        android:layout_width="wrap_content"
        android:layout_height="1dp"
        android:background="@color/colorPrimary"/>
</LinearLayout>

Actually, I want the same width for both textview content and View. But View width size same as full-screen width.

yash786
  • 1,151
  • 8
  • 18
Vijay Ram
  • 385
  • 5
  • 12

2 Answers2

0

To underline text in view You can edit in string like shown below,

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

and add this in to your text view like,

<TextView
    android:layout_width="wrap_content"
    android:text="@string/string_name"
    android:id="@+id/textview"
    android:layout_height="wrap_content" />

I hope this may will help you!!

-1

View view will always take fullscreen if you don't specify a width or height. So, you want to use CoordinatorLayout or RelativeLayout in order to make View width the same as TextView.

Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53
Davis
  • 137
  • 1
  • 6