0

My Floating button is not aligned where I want it. I want it next to the InputBox but also a bit more down on the layout. It is currently a bit above the InputBox I have seen the following Link and I have tried it but I could't get it working, Here is my layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_chat"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" />
    <RelativeLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/main_content"
        android:padding="10dp"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_below="@id/toolbar">
        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_send_black_24dp"
            android:id="@+id/fsend"
            android:clickable="true"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:tint="@android:color/white"
            android:layout_gravity="bottom|right"
            app:backgroundTint="#2196F3"
            app:elevation="6dp"
            app:fabSize="mini" />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Write message here"
            android:layout_toLeftOf="@+id/fsend"
            android:background="@drawable/bubble_reciever"
            android:layout_alignParentBottom="true"
            android:layout_alignParentStart="true"
            android:id="@+id/chat_input" />
        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:layout_alignParentStart="true"
            android:layout_above="@id/fsend"
            android:dividerHeight="16dp"
            android:divider="@android:color/transparent"
            android:id="@+id/list_of_messages"
            android:layout_marginBottom="16dp" />
    </RelativeLayout>
</RelativeLayout>

Here is a screenshotscreenshot

EDIT 1:

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Write message here"
    android:layout_toLeftOf="@+id/fsend"
    android:background="@drawable/bubble_reciever"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true"
    android:id="@+id/chat_input" />
<android.support.design.widget.FloatingActionButton
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentEnd="true"
  android:layout_alignBaseline="@id/chat_input"
      android:src="@drawable/ic_send_black_24dp"
      android:id="@+id/fsend"
      android:clickable="true"
      android:tint="@android:color/white"
      app:backgroundTint="#2196F3"
      app:fabSize="mini" />
Community
  • 1
  • 1
Donald Jansen
  • 1,937
  • 4
  • 22
  • 41

1 Answers1

0

I think if you add android:layout_alignBaseline="@id/chat_input" in your fab view it would do the work.

ATTENTION : you must swap the position of your fab and your edittext in your xml file.

Mohammad Zarei
  • 1,773
  • 14
  • 33