Android的ListView控件fastScrollThumbDrawable不工作 [英] Android ListView fastScrollThumbDrawable not working

查看:874
本文介绍了Android的ListView控件fastScrollThumbDrawable不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个应用程序,我想在我的ListView中fastscroll标签是一个自定义的拇指标签。阅读文档在线我认为这将做到这一点:

i am doing an app where i want the fastscroll tab on my listview to be a custom thumb tab. reading the docs online i thought this would do it:

<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
android:cacheColorHint="@color/myWhite"
android:scrollbars="vertical"
android:scrollbarThumbVertical="@drawable/scrollthumb"
android:scrollbarSize="12dip"
android:fastScrollThumbDrawable="@drawable/scrollbar_thumb"
android:fastScrollEnabled="true"
/>

列表视图是罚款,自定义滚动条的颜色正在和fastscrollbar选项卡中显示,但它使用的是默认的拇指图像,而不是的 PNG 的文件中的 scrollbar_thumb

不拇指图像需要在一定的格式或大小?
可以把它改成一个自定义的图形,如果不能够在拇指的颜色,至少可以改变?

does the thumb image need to be in a certain format or size ? can it be changed to a custom graphic, if not can the colour of the thumb be changed at least ?

任何帮助将非常AP preciated

any help will be much appreciated

推荐答案

在ListView的XML定义添加

In the ListView XML definition, add

android:fastScrollEnabled="true"

或code

listView.setFastScrollEnabled(true);

在res /可绘制文件夹中创建文件fastscroll_thumb.xml如下:

Create file fastscroll_thumb.xml in the res/drawable folder as follows:

<?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>

在AndroidManifest.xml中,设置自定义主题,为您的应用:

In AndroidManifest.xml, set a custom theme for your application:

<application
    android:theme="@style/ApplicationTheme"
    ...>

创建res文件夹一个文件夹值。创建RES /值的themes.xml文件内容如下:

Create a values folder in the res folder. Create themes.xml files in res/values as follows:

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

最后确保fastscroll.png和fastscroll_ pressed.png在绘制文件夹中存在

Lastly make sure that fastscroll.png and fastscroll_pressed.png exist in your drawable folder

这篇关于Android的ListView控件fastScrollThumbDrawable不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆