Android_RelativeLayout - 如何把两个元素放在同一行? [英] Android_RelativeLayout - How to put two elements on the same line?
本文介绍了Android_RelativeLayout - 如何把两个元素放在同一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在的问题是:我有一个TextView和一个EditText,我怎能把他们放在同一个级别
The question is: I have a TextView and an EditText, how can I place them on the same "level"?
http://postimage.org/image/o9l17a3zv/
正如你所看到的,我希望把用户名上的同级别的EditText ...
As you can see, I want to put "Username" on the same level of the EditText...
下面我code:
<TextView
android:id="@+id/account_creation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/account_creation"
android:textSize="20sp"
android:textStyle="bold" />
<!-- Username -->
<TextView
android:id="@+id/username_registration"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/account_creation"
android:layout_toLeftOf="@+id/username_new_account"
android:text="@string/user_text"
android:textSize="15sp" />
<EditText
android:id="@+id/username_new_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/account_creation"
android:layout_alignParentRight="true"
android:ems="10"
android:hint="@string/user_editext" >
<requestFocus />
</EditText>
我想穿上他们两个的高度的值相同,但我不知道这是否是正确的/更好的办法...
I was thinking to put the same value of "height" on both of them, but i don't know if it's the right/better way...
推荐答案
文本显示和编辑文本都在同一行感人的家长布局的底线
试试这个。
TEXT VIEW AND EDIT TEXT ARE ON THE SAME LINE TOUCHING THE BOTTOM LINE OF PARENT LAYOUT Try this one.
android:layout_alignBottom="@+id/editText1"
这一定会帮助你的。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parentView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/editText1"
android:text="TextView" />
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/textView1"
android:ems="10" >
<requestFocus />
</EditText>
</RelativeLayout>
感谢。
这篇关于Android_RelativeLayout - 如何把两个元素放在同一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文