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