我有一個問題,我想用自定義顏色或漸變填充擴展空間。然而,RecyclerView的工作方式是通過在項目之間留出空白空間來擴展行,從而導致看到白色背景(屏幕截圖)或任何背景色。膨脹動畫完成後,空白空間被填充,onBindViewHolder被調用。Recycler視圖notifyItemInserted空白空間
難道這可以解決方法,我可以用自定義視圖填充這個空白空間,所以它很好地epxanded沒有顏色閃爍?
有沒有一種方法可以將偵聽器附加到動畫上,並將其與虛擬視圖疊加在一起?
顯示權之後的子觀點:顯示
後子視圖(組已展開。)
編輯:添加RecyclerView的XML的要求
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
style="@style/myRecyclerViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
group_item.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/list_group_item_height"
android:background="@android:color/holo_green_light"
android:clickable="true"
android:foreground="?attr/selectableItemBackground">
<TextView
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"/>
</FrameLayout>
child_item.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height"
android:background="@android:color/holo_green_light"
android:clickable="true">
<TextView
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"/>
</FrameLayout>
即使我改變一切的高度,以WRAP_CONTENT它仍然是相同的,動畫只是epxands的意見,並留下一個空的空間(recyclerView的背景),我想以某種方式填寫。
這是從該庫中提取的:https://github.com/h6ah4i/android-advancedrecyclerview
張貼您的xml文件 –
@PratikPopat添加了RecyclerView的xml。 – box
和項目佈局? –