0
我有用于回收视图的自定义垂直滚动条,但用于显示项目位置的拇指有点过大,并且位于顶部(图片scroll_2) ,并且我需要按照第一张图片(图片scroll_1)上显示的大小进行尺寸调整。Android如何为回收视图制作自定义滚动条
在styles.xml我定义的thumb.xml和track.xml文件的自定义滚动条定制赛道和拇指。在recyler.xml中,我添加了style属性以显示自定义滚动条,并带有填充。
如何解决这个问题的任何想法,我试图在thumb.xml中更改宽度和高度,但它不起作用。谢谢!
Styles.xml文件:
<resources>
<style name="AppTheme" parent="@style/Theme.Leanback">
<item name="@attr/scrollbarStyle">@style/scrollbar_shape_style</item>
</style>
<attr name="scrollbarStyle" format="reference"/>
<style name="scrollbar_shape_style">
<item name="android:scrollbarAlwaysDrawVerticalTrack">true</item>
<item name="android:scrollbarStyle">outsideOverlay</item>
<item name="android:scrollbars">vertical</item>
<item name="android:fadeScrollbars">false</item>
<item name="android:scrollbarThumbVertical">@drawable/thumb</item>
<item name="android:scrollbarTrackVertical">@drawable/track</item>
<item name="android:scrollbarSize">8dp</item>
</style>
Thumb.xml文件:
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="0"
android:endColor="#ffffff"
android:startColor="#ffffff" />
<corners android:radius="5dp" />
<size android:width="8dp" />
<size android:height="3dp" />
Truck.xml文件:
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="0"
android:endColor="#9BA3C5"
android:startColor="#8388A4" />
<stroke
android:width="7dp"
android:color="#00ffffff"/>
Recycler.xml文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="383dp"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/network_setup_more_recycler"
style="@style/scrollbar_shape_style"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingEnd="50dp"
android:paddingStart="0dp"/>
尝试这个thumb.xml文件: - https://stackoverflow.com/questions/35399829/scrollbar-color-in-recyclerview –
谢谢,我试着但拇指仍然一样,我仍然有问题的高度 – alezniki
@alezniki:你试过设置 setSmoothScrollbarEnabled - fasle,以编程方式? – Radhey