安卓ListView滚动条

3

我创建了一个列表视图。我需要增加垂直滚动条的宽度。我更改了android:scrollbarSize,但是没有生效。我还想缩短滚动条拇指的长度。是否可能?请帮帮我。

<LinearLayout android:id="@+id/LinearLayout01" 
 android:layout_width="fill_parent" android:layout_height="fill_parent" 
 xmlns:android="http://schemas.android.com/apk/res/android">

<ListView 
 android:id="@+id/list_view"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:scrollbars="vertical"
 android:scrollbarAlwaysDrawVerticalTrack="true"
 android:scrollX="0px"
 android:scrollY="0px"
 android:background="#515151"
 android:layout_weight="1"
 android:scrollbarStyle="outsideOverlay"
 android:divider="#FFF"
 android:fadeScrollbars="false"
 android:scrollbarSize="20dip"/>

 </LinearLayout>

1
你能发布你的布局文件吗? - EboMike
将布局放入代码中...请检查它。 - Jithin
尝试设置android:layout_width="wrap_content"。 - Shaireen
我不能使用wrap_content。因为我正在对话框内使用列表视图,而该列表视图应填充对话框。 - Jithin
有人解决了这个问题吗?请在这里发布并帮助我。 - Charan Pai
2个回答

2

您的滚动条将根据您为 android:scrollbarTrackHorizontalandroid:scrollbarTrackVertical 指定的资源的宽度/高度进行缩放。

目前我所能想到的唯一方法似乎就是这样做了,我不会再对其进行任何修改了 ;)

因此,如果您想要一个8像素宽的水平轨道和一个12像素高的垂直轨道。请创建一个宽度为8像素的PNG文件用于水平轨道,创建一个高度为12像素的PNG文件用于垂直轨道。您的九宫格图片 android:scrollbarThumbHorizontalandroid:scrollbarThumbHorizontal 将自动在这些图像内缩放。

<item name="android:scrollbarTrackHorizontal">@drawable/png_12px_high</item>
<item name="android:scrollbarTrackVertical">@drawable/png_8px_wide</item>

1

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