fastScrollThumbDrawable
、fastScrollTrackDrawable
、または fastscroll のテキストの色を変更するにSectionIndexer
は、コンテキスト テーマを使用する必要があります。他の回答では、これを行うためにアプリケーションのテーマをオーバーライドすることを推奨しAndroidManifest
ています。それは機能しますが、スクロールバーごとに異なる外観が必要な場合は、それListView
を行うことはできません。また、テキストの色を変更する方法SectionIndexer
は、アプリのテーマで行うべきではありません。他の望ましくない効果が生じる可能性があるためです。
高速スクロール用に をスタイルする最良の方法は、 を使用ListView
するカスタムを作成することです。 ListView
ContextThemeWrapper
次に例を示します。
public class FastscrollThemedListView extends ListView {
public FastscrollThemedListView(Context context, AttributeSet attrs) {
super(new ContextThemeWrapper(context, R.style.FastScrollTheme), attrs);
}
}
必要なのはそれだけです。スタイルは次のようになります。
<style name="FastScrollTheme">
<item name="android:textColorPrimary">?android:textColorPrimaryInverse</item>
<item name="android:fastScrollThumbDrawable">@drawable/fast_scrollbar_thumb</item>
<item name="android:fastScrollTrackDrawable">@drawable/fast_scrollbar_track</item>
</style>
textColorPrimary
SectionIndexer
フックする方法は、フォントの色を使用する場合にフックする方法です。
ListView は次のようになります。
<com.yourapp.view.FastscrollThemedListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ListView"
android:fastScrollEnabled="true"
android:divider="@null"/>
必要に応じて、ThumbDrawable は次のようになります。
fast_scrollbar_thumb.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="10dp" android:bottom="10dp">
<shape android:shape="rectangle">
<size
android:height="45dp"
android:width="5dp" />
<solid android:color="#DA414A" />
</shape>
</item>
</layer-list>
私の知る限り、FastScroll バーを HoneyComb の前にスタイルする理由はありません (API 11)