开发者

Android ignores scrollbarsize

开发者 https://www.devze.com 2022-12-26 06:31 出处:网络
I\'m trying to modify a ListView scrollbar\'s width without success <ListView android:id=\"@+id/android:list\"

I'm trying to modify a ListView scrollbar's width without success

<ListView
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:choiceMode="singleChoice"
    android:scrollbars="vertical"
    android:scrollbarTrackVertical="@drawable/scrollbar_vertical_track"
    android:scrollbarThumbVertical="@drawable/scrollbar_vertical_thumb"
    android:scrollbarSize="4px"
    android:clickable="true"/>

First I tried using a drawable image 4px wide, but the .png was resized. Then I tried using a s开发者_JS百科hape extracted from SamplesApi, without success.

<shape 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:width="40px">
<gradient android:startColor="#505050" android:endColor="#C0C0C0"
        android:angle="0"/>
<corners android:radius="0dp" />

I've tried with and without the android:width attribute.

There's a question on the same topic (Width of a scroll bar in android), but it doesn't try anything different that what I'm already trying. As far as I know, creating my own theme shouldn't change the output.

There's an example in SamplesApi (Views/ScrollBars). I tried modifying the scrollbarSize attribute without result.

I know about ninepatch images, but there's an attribute which should do what I want.

Any hint? Thanks in advance.


By my experience, Android ignores scrollbarSize, and computes size of both scrollbars from height of horizontal scroll track drawable (PNG image) which is set by android:scrollbarTrackHorizontal.


Did you tried

android:scrollbarSize="wrap_content"

and then just putting the size thru shape? I had kind of the same problem like this and I solved it in that way

0

精彩评论

暂无评论...
验证码 换一张
取 消