Can this be used also for RecyclerView that using GridLayoutManager?
topex-psy opened this issue · 0 comments
topex-psy commented
I see an example of your project using LinearLayoutManager
. I what to try this library because it looks useful, but my RecyclerView
is using GridLayoutManager
and the scrollbar not showing up. Is this because the layout manager or something else?
define layout manager:
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val layoutManager = GridLayoutManager(context, 6)
layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
return Math.min(6, if (listProdukAdapter == null) 2 else listProdukAdapter!!.getItemViewType(position))
}
}
recycler_view.setHasFixedSize(true)
recycler_view.layoutManager = layoutManager
recycler_view.addOnScrollListener(object : MyRecyclerViewScroll() {
override fun hide() = frg.hideBar()
override fun show() = frg.showBar()
})
...
}
setting adapter & bubble scrollbar:
listProdukBeli = listProduk.lisT_PRODUK.toMutableList()
listProdukAdapter = ListProdukAdapter(context!!, listProdukBeli!!, act, "beli")
recycler_view.adapter = listProdukAdapter
bubbleScrollBar.attachToRecyclerView(recycler_view)
bubbleScrollBar.bubbleTextProvider = BubbleTextProvider { listProdukBeli!![it].kategori }
For the bubbleTextProvider, I'm getting the category
value of my product list.
my layout:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="120dp"
android:paddingBottom="70dp"
android:scrollbars="vertical"
android:visibility="visible"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.trendyol.bubblescrollbarlib.BubbleScrollBar
android:id="@+id/bubbleScrollBar"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:orientation="vertical"
android:paddingTop="120dp"
android:paddingBottom="70dp"
app:bubbleBackground="@drawable/fast_scroll_thumb"
app:bubbleElevation="6dp"
app:bubbleHeight="50dp"
app:bubbleMargin="4dp"
app:bubbleMinWidth="50dp"
app:bubblePadding="4dp"
app:bubbleTextColor="@color/default_bubble_text_color"
app:bubbleTextSize="8sp"
app:scrollbarBackground="@color/bubbleRed"
app:thumbBackground="@color/colorAccent" />
</FrameLayout>