문제

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