2015-11-05 2 views

ответ

1

Эта функция работает только тогда, когда ваш родитель расположение является координатором layout.This может быть достигнуто с помощью app:layout_anchor="" и app:layout_anchorGravity=""

Некоторые вещи, как это:

<?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/com.example.myapp" 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:background="#ffffff" 
    > 
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content" 
              android:layout_width="match_parent" 
              android:id="@+id/appBar" 
     > 
    <!-- Put your content that is supposed to be in the appbar here --> 

</android.support.design.widget.AppBarLayout> 
<android.support.design.widget.FloatingActionButton 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:src="@drawable/your_drawable_resource_file" 
     app:borderWidth="0dp" 
     app:fabSize="normal" 
     app:layout_anchor="@id/appBar" 
     app:layout_anchorGravity="left|bottom|start"/> 
</android.support.design.widget.CoordinatorLayout> 

Надежда это было полезно.

1

Если родительский макет Относительный Layout. Просто используйте

android:layout_alignParentRight="true" 
    android:layout_alignParentBottom="true" 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:clickable="true" 
android:orientation="vertical"> 



    <android.support.design.widget.FloatingActionButton 
    android:layout_alignParentRight="true" 
    android:layout_alignParentBottom="true" 
    android:id="@+id/myFAB" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/ic_plus_sign" 
    app:elevation="4dp" 
/> 

</RelativeLayout> 
+1

dont work for me:/ – Muffin

+0

Вы можете предоставить свой xml-файл для получения дополнительной справки –

+1

У меня нет xml непосредственно для этой проблемы ^^ Мне просто нужно это, как на скриншоте, прикрепленном к моему вопросу – Muffin

Смежные вопросы