Search code examples
androidandroid-layoutfloating-action-button

How to Place a FAB at the end | left?


How change place FAB from right to left in RTL ? The problem is that the FAB is Can't changing position in RTL

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:padding="20dp">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="false"
        android:layout_gravity="left|end"
        android:layout_marginBottom="16dp"
        android:layout_marginRight="16dp"
        app:backgroundTint="@color/colorPrimary"
        app:borderWidth="0dp"
        app:elevation="8dp"
        app:fabSize="normal"
        app:srcCompat="@drawable/add_icon" />


</RelativeLayout>

I want the FAB as like in the image


Solution

  • Add this to floating button xml

    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"