Tôi có các Nút Hành động Nổi trong hai bố cục Phân đoạn của tôi và đôi khi chúng di chuyển đến vị trí sai, tôi sử dụng CoordinatorLayout.Android: Nút Hành động Nổi ở vị trí sai
This is how it somtetimes look when i open the Fragment
Đây là mã của đoạn tôi:
<?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>
Có ai có một ý tưởng tại sao FAB đôi khi di chuyển đến vị trí sai?
theo xml của bạn có quan điểm tái chế nhưng ảnh chụp màn hình cho thấy TextView? –
@Sangram textview là ViewHolder. Nó được hiển thị khi khung nhìn của người tái chế trống. – Cimoe
bạn cũng có thể đặt trọng lực theo chương trình sang FAB.kiểm tra câu trả lời của tôi. –