如何放置两个直线的Android之间的文本? [英] How to place a text between two straight line android?
本文介绍了如何放置两个直线的Android之间的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将直线之间的文本。我试图通过使用视图,但是TextView中自带的线以下。如何解决此问题?
我的code是如下:
< RelativeLayout的
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =10dp >
<查看 机器人:layout_width =WRAP_CONTENT
机器人:layout_height =2DP
机器人:layout_alignParentLeft =真
机器人:layout_toLeftOf =@ + ID / orText
机器人:背景=#C0C0C0/>
<查看
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =2DP
机器人:背景=#C0C0C0
机器人:layout_toRightOf =@ + ID / orText
机器人:layout_alignParentRight =真/> <的TextView
机器人:ID =@ + ID / orText
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentTop =真
机器人:layout_centerHorizontal =真
机器人:文字=OR
机器人:文字颜色=@机器人:彩色/黑白/> < / RelativeLayout的>
下面是截图,
解决方案
< RelativeLayout的
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =center_vertical | CENTER_HORIZONTAL
机器人:layout_marginTop =10dp> <查看
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =2DP
机器人:layout_centerVertical =真
机器人:layout_toRightOf =@ + ID / orText
机器人:背景=#C0C0C0/> <的TextView
机器人:ID =@ + ID / orText
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentTop =真
机器人:layout_centerHorizontal =真
机器人:文字=OR
机器人:文字颜色=@机器人:彩色/黑白/> <查看
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =2DP
机器人:layout_centerVertical =真
机器人:layout_toLeftOf =@ + ID / orText
机器人:背景=#C0C0C0/>
< / RelativeLayout的>
I need to place a text between a straight line. I tried by using view but textview comes below the line. How to solve this? My code is as follows:
<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>
Here is screenshot,
解决方案
<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>
这篇关于如何放置两个直线的Android之间的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文