0
<?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> 

Вот вид в андроиде дизайна студии, линейная компоновка отображается ли соответствует родителю:Линейного матч расположения родитель или вес не работает в макете координатора

enter image description here

Но выход:

enter image description here

линейная планировка не соответствует родителю или я подозреваю, что layout_weight применяется к двум плавающим б uttons не работает в расположении координатора.

+0

Вы пробовали 'андроида: layout_gravity = "Дно | center_horizontal"' –

+0

@ SelçukCihan просто пробовал, не работает:/ – Alex

+0

Вы можете также изменить 'андроида: layout_width = "match_parent"' 'для Android: layout_width = "wrap_content" 'в линейном макете? –

ответ

2

Это потому, что FloatingActionButton может иметь фиксированный размер.

Вы можете добавить себе свободное пространство.

<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> 
Смежные вопросы