<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.now.sexyfacechanger.Activity_PhotoOrGallery">
<include layout="@layout/content_activity__photo_or_gallery" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_camera"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_camera"
android:layout_weight="1"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_gallery"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_gallery"
android:layout_weight="1"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Here is the view in android studio design, the linear layout displayed does match the parent:
But the output:
The linear layout doesn't match parent or I suspect the layout_weight applied to the two floating buttons doesn't work in Coordinator layout.
It is because FloatingActionButton
can only have a fixed size.
You can add some space between them.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal">
<Space
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_camera"/>
<Space
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_gallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_gallery"/>
<Space
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
</LinearLayout>