In my app I have a FloatingActionButton
in a ListFragment
.
Here is the layout of the ListFragment
:
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@android:layout/list_content"/>
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/no_contacts"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_add"
app:layout_anchor="@id/android:list"
app:layout_anchorGravity="bottom|end"
android:layout_alignParentEnd="true"/>
</android.support.design.widget.CoordinatorLayout>
In Android Studio the FAB is at the bottom-right
position but when I run the app it's at the top-left
.