我需要定制快速滚动字母预览(截图中的大M)并使用自定义背景资产,但我找不到任何相关文档。你能帮我吗?
<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>
c_fastscroller_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 文件中:
<!-- 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>
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>
其中fastScroll_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>
fastfastscroll_thumb_pressed/fastscroll_thumb_default是可自定义的可绘制对象,您可以根据自己的喜好进行自定义。
提示:不要忘记在清单文件中将样式设置为您的活动。
如果我错了,请纠正我,但我认为已经有很多讨论相同问题的问题了。
祝你好运。