CoordinatorLayout layout_anchor does not work

前端 未结 1 1740
甜味超标
甜味超标 2021-01-04 02:30

I just tried out the new Support Design Library with CoordinatorLayout, but I\'m having problems anchoring child views. My layout currently looks like this:

         


        
相关标签:
1条回答
  • 2021-01-04 03:03

    Try this code. You need to use app:layout_behavior in your RecyclerView

    <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_marginBottom="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:src="@drawable/ic_fab_add"
        android:onClick="onAddPlayerClick"
        app:elevation="4dp"
        app:borderWidth="0dp"
        app:layout_anchor="@id/appbar"
        app:layout_anchorGravity="bottom|right|end"
        android:clickable="true"/>
    
    0 讨论(0)
提交回复
热议问题