安卓忽略滚动条大小

4

我试图修改ListView滚动条的宽度,但没有成功。

<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"/>

首先,我尝试使用一个宽度为4像素的可绘制图像,但是.png文件被调整大小了。然后我尝试使用从SamplesApi中提取的形状,但没有成功。

<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" />

我已经尝试使用和不使用android:width属性。

有一个关于同一主题的问题 (Width of a scroll bar in android),但它没有尝试任何不同于我正在尝试的东西。据我所知,创建自己的主题不应该改变输出结果。

SamplesApi(Views/ScrollBars)中有一个示例。我尝试修改scrollbarSize属性,但没有结果。

我知道有九宫格图片,但有一个属性可以实现我想要的效果。

有什么提示吗?提前感谢。

2个回答

1
根据我的经验,Android 忽略了 scrollbarSize,并且计算两个滚动条的大小都基于横向滚动轨道 drawable(PNG 图片)的高度,该图片是由 android:scrollbarTrackHorizontal 设置的。

-5

你试过了吗?

android:scrollbarSize="wrap_content"

然后只需通过形状来确定大小?我之前也遇到过类似的问题,我是用这种方法解决的


1
不允许使用字符串类型(在“scrollabarsize”中的值为“wrap_content!”)。 - user685738

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接