user2224350
user2224350

Reputation: 2304

Android underline whole textView

is it possible to underline a whole textView (layout_width = fill_parent) and not just its text? Edit: The text of the TextView should be like a kind of header. So I have text above this header and text below the header. To seperate the two sections clearly I want a line directly below the header which goes through the whole width of the layout. When the header-textView's width is set to fill_parent, the whole textView should be underlined and not just its text..

regards

Upvotes: 1

Views: 2411

Answers (1)

Steve M
Steve M

Reputation: 9784

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Activity A" />
    <View
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:background="#000" />

</LinearLayout>

Here's a nicer way for headers:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+android:id/title"
        style="?android:attr/listSeparatorTextViewStyle"
        android:text="Units" />

</LinearLayout>

Upvotes: 6

Related Questions