Reputation: 3565
In my android layout, I have two EditText elements. They appear side by side at the bottom of the screen. But when i type multiple lines into the first EditText(on the left), the second one(at the right) also keeps moving upwards even though it is empty. I have specified android:layout_gravity="bottom"
and android:gravity="bottom"
for the second EditText. But it has no effect. What am i doing wrong? How can i make the second EditText stay at the vertical center of its parent linear layout, no matter how many lines are entered in the first EditText.
<?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">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/bg_textinput"
android:layout_alignParentBottom="true">
<EditText
android:id="@+id/text_input"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.7"
android:inputType="textMultiLine" />
<EditText
android:id="@+id/text_input1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
android:layout_weight="0.3"
android:inputType="textMultiLine" />
</LinearLayout>
</RelativeLayout>
Upvotes: 2
Views: 2375
Reputation: 403
This will work:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:gravity="center">
<EditText
android:id="@+id/text_input"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:inputType="textMultiLine" />
<EditText
android:id="@+id/text_input1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="bottom"
android:layout_weight="0.3"
android:inputType="textMultiLine" />
</LinearLayout>
Upvotes: 1
Reputation: 3322
try this,
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText
android:id="@+id/text_input"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.7"
android:inputType="textMultiLine" />
<EditText
android:id="@+id/text_input1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.3"
android:gravity="bottom"
android:inputType="textMultiLine" />
</LinearLayout>
Upvotes: 0