0

在应用程序列表视图中,我在列表视图中有 1000 多个数据,并且滚动起来很乏味。我尝试更改滚动条但无法更改。我需要滚动条,如下图所示

<ListView
 android:id="@+id/listview"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:layout_below="@+id/layoutProduct"
 android:background="#00000000"
 android:cacheColorHint="#00000000"
 android:dividerHeight="1dp"
 android:fadeScrollbars="true"
 android:fadingEdge="none"
 android:scrollbarSize="10dp"
 android:scrollbarThumbVertical="@drawable/a_apptheme_fastscroll_thumb_holo"
 android:focusable="true"
 android:focusableInTouchMode="true"
 android:listSelector="#00000000"
 android:scrollingCache="false" >
 </ListView>

拇指图像

用户可以拖动滚动条

4

2 回答 2

1

调用setFastScrollEnabled(true);ListView 上的方法。http://developer.android.com/reference/android/widget/AbsListView.html#setFastScrollEnabled(boolean)

于 2014-08-25T10:36:13.477 回答
0

在您的 ListView XML 定义中,添加

android:fastScrollEnabled="true"
android:fastScrollAlwaysVisible="true"

在 res/drawable 文件夹中创建文件 fastscroll_thumb.xml 如下:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:state_pressed="true" android:drawable="@drawable/fastscroll_pressed" />
      <item android:drawable="@drawable/fastscroll" />
</selector>

在 res 文件夹中创建一个 values 文件夹。在 res/values 中创建 theme.xml 文件,如下所示:

<resources>
  <style name="ApplicationTheme">
      <item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb</item>
  </style>
</resources>
于 2014-08-25T12:36:52.173 回答