Skip to content Skip to sidebar Skip to footer

Align Button And Edittext On Relative Layout

I have this code as the footer of my listview. Its just an EditText and a Button to send messages.

Solution 1:

You need to do:

  1. Set android:layout_alignParentBottom="true" to both your edittext and button.
  2. Set android:layout_alignParentLeft="true" to edittext.
  3. Set android:layout_toRightOf="@+id/edittextid" to button.

Adding your modified code for footer:

<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/InnerRelativeLayout"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_marginTop="10dp"android:paddingTop="5dp"android:paddingRight="3dp"android:paddingLeft="3dp"><EditTextandroid:id="@+id/et_sent_msg"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_toLeftOf="@+id/bt_sent_msg" ></EditText><Buttonandroid:text="Enviar"android:id="@+id/bt_sent_msg"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="15dp"android:textStyle="bold"android:gravity="center"android:textColor="@color/black"android:layout_alignParentBottom="true"android:layout_alignParentRight="true" /></RelativeLayout>

Solution 2:

Allign edit text to bottom left corner of the parent. Then allign you button to the right of edit text and allign button top to edit text top and button bottom to edit text bottom

Post a Comment for "Align Button And Edittext On Relative Layout"