2012-02-29 101 views
0

基本上我想得到如图所示的效果。 TextView两侧的水平线。我怎样才能做到这一点?水平线填充TextView和父项之间的空间

enter image description here

+0

你做这个使用XML或编程,我的意思是你只有两个头和文本? – 2012-02-29 14:58:11

+0

@Samir只是XML - 它不可编辑 – gisek 2012-02-29 15:36:21

回答

1

其易象:

<View 
     android:id="@+id/hline1" 
     android:layout_width="fill_parent" 
     android:layout_height="5dip" 
     android:layout_marginBottom="2dp" 
     android:layout_marginTop="10dp" 
     android:background="#000000" /> 

你的XML布局就像是::

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

    <View 
     android:id="@+id/hline1" 
     android:layout_width="fill_parent" 
     android:layout_height="5dip" 
     android:layout_marginBottom="2dp" 
     android:layout_marginTop="10dp" 
     android:layout_toLeftOf="@+id/header1" 
     android:background="#000000" /> 

    <TextView 
     android:id="@+id/header1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:text=" Header " 
     android:textColor="#000000" 
     android:textSize="20dp" 
     android:textStyle="bold" /> 

    <View 
     android:id="@+id/hline2" 
     android:layout_width="fill_parent" 
     android:layout_height="5dip" 
     android:layout_marginTop="10dp" 
     android:layout_toRightOf="@+id/header1" 
     android:background="#000000" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/header1" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="5dp" 
     android:text="Some Text Goes to here..........................." 
     android:textColor="#000000" /> 

</RelativeLayout> 
0

创建一个简单的形状绘制,并设置为在TextView的左/右可绘制。 TextView宽度必须是Fill_Parent。