2017-06-05 52 views
0

FAB的行爲是意外的。圖片在下面的鏈接浮動操作按鈕不想要的行爲與回收視圖android

找不到任何幫助..它確實有用,有時不。 不能夠找到實際的問題 甚至試圖在allHere是XML動態添加像

CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) btnSubmitConfirm.getLayoutParams(); 
    params.setAnchorId(R.id.listWorkData);   
params.anchorGravity = Gravity.BOTTOM | GravityCompat.END | Gravity.RIGHT;   
btnSubmitConfirm.setLayoutParams(params); 

但是這麼想的工作codeneed解決傢伙

<?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:id="@+id/parentView" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:animateLayoutChanges="true" 
android:background="@color/background" 
android:clickable="true"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/listWorkData" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:padding="@dimen/ten" /> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/btnConfirmSubmitReport" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentEnd="true" 
    android:layout_alignParentRight="true" 
    android:layout_margin="@dimen/thirty" 
    android:src="@drawable/ic_tick" 
    android:tint="@android:color/white" 
    app:layout_anchor="@id/listWorkData" 
    app:layout_anchorGravity="bottom|right|end" /> 

[OK條件圖像] [1] [不合適條件圖像] [2] [1]:https://i.stack.imgur.com/7D0XD.png [2]:https://i.stack.imgur.com/ds2Gi.png

+0

刪除應用程序:layout_anchor和應用程序:layout_anchorGravity – Rohit

+0

@Rohit什麼樣的建議實際上是?我確實需要回收站底部的FAB –

回答

0

刪除該信息,

app:layout_anchor="@id/listWorkData" 
app:layout_anchorGravity="bottom|right|end" 

並檢查。

+0

真的嗎?我相信那不是我的解決方案。我確實希望FAB在最右邊。 –

0

我做了一個小的調整,使其按需要工作 我只是添加了監聽器來檢查回收者視圖是否已更新並對其中的FAB進行了更改。

​​
相關問題