Я использую CoordinatorLayout
в качестве корневого представления. Он содержит RelativeLayout
и FloatingActionButton
. Когда я установил layout_anchor
и layout_anchorGravity
для FloatingActionButton
, он не центрировался на краю RelativeLayout
(оранжевая область на экране), как я ожидал.
Я попробовал решение этого вопроса Как я могу добавить новую кнопку плавающего действия между двумя виджетами/макетами, но безуспешно.
Вот мой макет:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/primary_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primary"
android:paddingBottom="30dp">
<com.vocabularyminer.android.android.view.view.FloatingEditText
android:id="@+id/edittext_package_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_marginTop="16dp"
android:hint="Test fab button"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_done_white_24dp"
app:elevation="4dp"
app:layout_anchor="@id/primary_area"
app:layout_anchorGravity="bottom|right|end"/>
</android.support.design.widget.CoordinatorLayout>
Что я ожидал: