سؤال

I have a Listview and I want to give the scrollbar a style :

<style name="scrollbar">
        <item name="android:scrollbarAlwaysDrawVerticalTrack">true</item>
        <item name="android:scrollbarStyle">outsideOverlay</item>
        <item name="android:scrollbars">vertical</item>
        <item name="android:fadeScrollbars">true</item>
        <item name="android:scrollbarThumbVertical">@drawable/apptheme_fastscroll_thumb_holo</item>

    </style>

This works fine :P but no track here I would like it scrollbarVertical Track to be black thin line. I tried this drawable for line :

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"   android:shape="rectangle"  >
    <stroke android:width="1dp" android:color="@android:color/black"/>
    <size android:width="2dp" />
</shape>

But if I append this to scrollbar style like

<item name="android:scrollbarTrackVertical">@drawable/track</item>

I cant see the thumb ...

هل كانت مفيدة؟

المحلول

It looks like you're missing transparency on the track drawable, so the thumb isn't visible when the style is applied. Try adding this to your @drawable/track.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android"   
    android:shape="rectangle" >

    <!-- add transparency to ensure thumb visibility -->
    <solid
        android:color="#00000000" />

    <stroke 
        android:width="1dp" 
        android:color="@android:color/black" />

    <size 
        android:width="2dp" />
</shape>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top