Android 下划线整个 textView [英] Android underline whole textView
问题描述
是否可以在整个 textView 下划线(layout_width = fill_parent)而不仅仅是它的文本? TextView 的文本应该像一种标题.所以我在这个标题上方有文字,在标题下方有文字.为了清楚地分隔这两个部分,我希望在标题正下方有一条线,它穿过布局的整个宽度.当 header-textView 的宽度设置为 fill_parent 时,整个 textView 应该加下划线,而不仅仅是它的文本..
is it possible to underline a whole textView (layout_width = fill_parent) and not just its text? 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..
问候
推荐答案
<?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>
这篇关于Android 下划线整个 textView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!