Android 如何自定义快速滚动预览字母
我需要使用自定义背景资源自定义快速滚动字母预览(屏幕截图中的大M),但我找不到任何关于它的文档。你能帮我吗Android 如何自定义快速滚动预览字母,android,customization,fastscroll,Android,Customization,Fastscroll,我需要使用自定义背景资源自定义快速滚动字母预览(屏幕截图中的大M),但我找不到任何关于它的文档。你能帮我吗 您可以通过在res/values/styles.xml <style name="AppTheme" parent="AppBaseTheme"> <item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb</item> <item name="an
您可以通过在
res/values/styles.xml
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb</item>
<item name="android:fastScrollOverlayPosition">atThumb</item>
<item name="android:fastScrollTextColor">@color/your_color</item>
<item name="android:fastScrollTrackDrawable">@drawable/fastscroll_thumb_pressed</item>
</style>
@可拉拔/快速滚动\u拇指
阿图姆
@颜色/你的颜色
@可拖动/快速滚动\u拇指\u按下
其中fastcroll\u thumb是一个选择器
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/fastscroll_thumb_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/fastscroll_thumb_default"/>
</selector>
和fastscroll\u thumb\u按下/fastscroll\u thumb\u默认值都是您可以根据自己的喜好定制的可拉式屏幕
注意:不要忘记在清单中为您的活动设置样式
如果我错了,请纠正我,但我认为已经有很多问题在讨论同一个问题
祝你好运。多亏了@MAB并查看了棒棒糖源代码,我成功地获得了我所需要的东西 Myc\u fastscroller\u preview.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="44dp"
android:topRightRadius="44dp"
android:bottomLeftRadius="44dp" />
<padding
android:paddingLeft="22dp"
android:paddingRight="22dp" />
<solid android:color="@color/c_red_e60000" /></shape>
<!-- This belongs in a FastScroll style -->
<item name="android:fastScrollThumbDrawable">@drawable/c_fastscroller_thumb</item>
<item name="android:fastScrollPreviewBackgroundRight">@drawable/c_fastscroller_preview </item>
<item name="android:fastScrollOverlayPosition">aboveThumb</item>
<item name="android:fastScrollTextColor">@color/c_white</item>
其中c_fastcoller_thumb.xml是:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/c_fastscroll_thumb" />
<item
android:drawable="@drawable/c_fastscroll_thumb" /></selector>
在我的应用程序styles.xml中:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="44dp"
android:topRightRadius="44dp"
android:bottomLeftRadius="44dp" />
<padding
android:paddingLeft="22dp"
android:paddingRight="22dp" />
<solid android:color="@color/c_red_e60000" /></shape>
<!-- This belongs in a FastScroll style -->
<item name="android:fastScrollThumbDrawable">@drawable/c_fastscroller_thumb</item>
<item name="android:fastScrollPreviewBackgroundRight">@drawable/c_fastscroller_preview </item>
<item name="android:fastScrollOverlayPosition">aboveThumb</item>
<item name="android:fastScrollTextColor">@color/c_white</item>
@可拖动/c\u快速滚动器\u拇指
@可绘制/c\u快速滚动体\u预览
大拇指
@颜色/颜色/白色
看看我的答案。它在棒棒糖上非常有效,但在以前的Android版本中,fastScrollPreview根本不显示。我该怎么解决呢?奇怪!Holo似乎不能处理上面的Thumb,而只能处理floating和atThumb(Holo源代码中的默认值)。但是使用其中一种材质形状不太合适。因此,您可以尝试使用具有不同覆盖位置和预览的Holo特定样式。