Android

here is my list

<ListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/ListView" android:fastScrollEnabled="true" android:divider="@null" style="@drawable/listviewfastscrollstyle" ></ListView> 

This is a listviewfastscrollstyle style file

 <style> <item name="android:fastScrollTrackDrawable">@drawable/listselector</item> <item name="android:fastScrollThumbDrawable">@drawable/listselector</item> </style> 

This is a listselector file

 <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/channelarrows_down" /> <item android:drawable="@drawable/minimize" /> </selector> 

But still, the quick view list pane is not configurable.

+6
source share
2 answers

The style you created is incorrect. You must give him a name. I'm not sure what happened to your last post about this. Follow these steps:

 <?xml version="1.0" encoding="utf-8"?> <resources> <style name="listviewfastscrollstyle" parent="android:Theme"> <item name="android:fastScrollTrackDrawable">@drawable/listselector</item> <item name="android:fastScrollThumbDrawable">@drawable/listselector</item> </style> </resources> 

In your manifest, set the style as follows:

 <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/CustomTheme"> 

As requested, this is a ListView on which I tested:

 <ExpandableListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:drawSelectorOnTop="false" android:fastScrollAlwaysVisible="true" android:fastScrollEnabled="true" android:indicatorLeft="8dip" android:indicatorRight="52dip" android:paddingRight="32dip" /> 
+9
source

To change fastScrollThumbDrawable , fastScrollTrackDrawable or fastscroll SectionIndexer text color, you must use a contextual theme. Other answers recommend overriding the application theme via AndroidManifest to do this. This really works, but if you want different scrollbars to appear behind the ListView , you cannot do this. In addition, the way to change the color of text on SectionIndexer should not be done in the application theme, as it may have other undesirable effects.

The best way to style a ListView for quick browsing is to create a custom ListView that uses ContextThemeWrapper .

Here is an example:

 public class FastscrollThemedListView extends ListView { public FastscrollThemedListView(Context context, AttributeSet attrs) { super(new ContextThemeWrapper(context, R.style.FastScrollTheme), attrs); } } 

That is all you need. Your style will look like this:

 <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 is how you connect to how you connect to the SectionIndexer font color if you use it.

Your ListView will look like this:

 <com.yourapp.view.FastscrollThemedListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/ListView" android:fastScrollEnabled="true" android:divider="@null"/> 

and if necessary it will look like this: 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> 

AFAIK no reason for FastScroll pre-HoneyComb panel style (API 11)

+7
source

Source: https://habr.com/ru/post/907907/


All Articles