我需要在直线之间放置文本。我尝试使用视图,但文本视图位于该行下方。怎么解决这个问题呢?
我的代码如下:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
>
<View
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/orText"
android:background="#c0c0c0"/>
<View
android:layout_width="wrap_content"
android:layout_height="2dp"
android:background="#c0c0c0"
android:layout_toRightOf="@+id/orText"
android:layout_alignParentRight="true"/>
<TextView
android:id="@+id/orText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="OR"
android:textColor="@android:color/black" />
</RelativeLayout>
这是截图,
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginTop="10dp" >
<View
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/orText"
android:background="#c0c0c0" />
<TextView
android:id="@+id/orText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="OR"
android:textColor="@android:color/black" />
<View
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/orText"
android:background="#c0c0c0" />
</RelativeLayout>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)