The question is: I have a TextView and an EditText, how can I place them on the same \"level\"?
http://postimage.org/image/o9l17a3zv/
As you can see, I want to p
Use the android:layout_toRightOf
or android:layout_toLeftOf
attributes, exclusive to relative layouts
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="TextView" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_toRightOf="@+id/textView1">
<requestFocus />
</EditText>
</RelativeLayout>
You have to center your text in the TextView widget for that just use the android attribute android:gravity
in your TextView xml declaration.
If you want Your text to get centered vertically and horizontally use:
android:gravity="center"
If you want Your text to get centered only horizontally use:
android:gravity="center_horizontal"
android:gravity="center"
is the solution
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"
This will surely help you.
<?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>
Thanks.
try this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/account_creation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="account_creation"
android:textSize="20sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/account_creation" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="user_text" />
<EditText
android:id="@+id/editText1"
android:hint="Enter_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_toRightOf="@+id/textView1" >
</EditText>
</RelativeLayout>
</RelativeLayout>