【问题标题】:Android Scrollview thumview changeAndroid Scrollview thumview 更改
【发布时间】:2014-10-18 11:00:23
【问题描述】:

在应用程序列表视图中,我在列表视图中有 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>

用户可以拖动滚动条

【问题讨论】:

    标签: android android-scrollbar


    【解决方案1】:

    【讨论】:

    • 感谢它在最新的 api 中工作,它看起来不同,但我想要的正是我想要的东西
    • 你可以改变 Drawable 的样式。如果我没记错的话。
    • 喜欢这个 android:scrollbarThumbVertical="@drawable/a_apptheme_fastscroll_thumb_holo"?
    • android:fastScrollThumbDrawable 添加到您的主题中。
    【解决方案2】:

    在您的 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中创建themes.xml文件如下:

    <resources>
      <style name="ApplicationTheme">
          <item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb</item>
      </style>
    </resources>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-03
      • 2020-12-10
      相关资源
      最近更新 更多