У меня есть плавающие кнопки действий в двух моих макетах фрагментов, и иногда они перемещаются в неправильное положение, хотя я использую CoordinatorLayout.Android: плавающая кнопка действия в неправильном положении
This is how it somtetimes look when i open the Fragment
Это код моего фрагмента:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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">
<LinearLayout android:id="@+id/notes_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.NotesFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/notes_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/new_note_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:src="@drawable/ic_add_black_48dp"
app:layout_anchor="@id/notes_layout"
app:layout_anchorGravity="bottom|center"
android:onClick="openNewNote"/>
</android.support.design.widget.CoordinatorLayout>
Кто-нибудь есть идея, почему FAB иногда двигаться в неправильном положении?
согласно вашему XML есть вид утилизатора, но скриншот показывает TextView? –
@Sangram textview - это ViewHolder. Он отображается, когда просмотр ресайклера пуст. – Cimoe
вы также можете программно настроить гравитацию на FAB.check мой ответ. –