I've got a RecyclerView
and would like to have scrollbar showing, when it covers more than one page.
I get no scrollbar at all. Any idea?
My layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<CheckBox
android:id="@+id/cl_only_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="5dp"
android:text="@string/cl_only_empty"
android:textColor="@color/white" />
<android.support.v7.widget.RecyclerView
android:id="@+id/callsList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
</LinearLayout>
I had the same problem on my old HTC Desire X (api 16) only.
I don't know why, but scollbars of
RecyclerView
doesn't work properly on this device if theandroid:background
property is not set. Try to set it to any color or to transparent - it works for me, hope it helps you tooTry this:
Besides the android:scrollbars attribute, you should add android:fadeScrollbars attribute in false state like this:
This way, the vertical scrollbar is always showing when it's using more height of the layout permitted.
Actually, it's because of the theme. The scrollbars are there but can't be seen because they blend with the color on the parent view or some other view in the line of its ancestors.
You can create a drawable shape and give it the color you want then set that as the vertical or horizontal scrollbar drawable. That is, if you do not want to mess around with your theme colors.
The solution is to set the vertical (or horizontal) scrollbar in the xml layout: