自定义FastScroller android

时间:2017-05-04 18:23:31

标签: android android-layout listview

我使用Section Indexer实现了快速滚动条,但是fastScrollPreviewBackgroundRight drawable中的文本正在被放大。我想实现图像scroll_image之类的东西 这是我谈到的放大图像current_image

我的styles.xml

<style name="GuideFastScroll" parent="Theme">
    <item name="android:fastScrollThumbDrawable">@drawable/scroll_thumb_holo</item>
    <item name="android:fastScrollOverlayPosition">atThumb</item>
    <item name="android:fastScrollTextColor">@color/black</item>
    <item name="android:fastScrollPreviewBackgroundRight">@drawable/scroll_scrolling_preview</item>
    <item name="android:fastScrollTrackDrawable">@null</item>
</style>

scroll_thumb_holo.xml

<item android:drawable="@drawable/scroll_active" android:state_pressed="true"/>
<item android:drawable="@drawable/scroll_inactive"/>

我的适配器

private class ChannelsAdapter extends ArrayAdapter<GuideChannel> implements SectionIndexer {

    private HashMap<String, Integer> fastScrollChannelMapIndex;
    private String[] fastScrollChannelSections;

    ChannelsAdapter(Context context, ImageViewLoader imageViewLoader, List<GuideChannel> guideChannelPresentationModels) {
        super(context, 0, 0, guideChannelPresentationModels);
        fastScrollChannelMapIndex = new LinkedHashMap<>();
        for(int x=0; x < guideChannelPresentationModels.size(); x++){
            String channelName = guideChannelPresentationModels.get(x).getName();
            if(channelName != null) {
                String channelInScroll=channelName;
                if (channelName.length() <= 0) {
                } else if (channelName.length() <= 3) {
                } else {
                    channelInScroll = channelName.substring(0, 3);
                }
                fastScrollChannelMapIndex.put(channelInScroll.toUpperCase(), x);
            }
        }

        Set<String> sectionIndex = fastScrollChannelMapIndex.keySet();
        ArrayList<String> sectionList = new ArrayList<>(sectionIndex);
        Collections.sort(sectionList);
        fastScrollChannelSections = new String[sectionList.size()];
        sectionList.toArray(fastScrollChannelSections);

    }

    @Override
    public Object[] getSections() {
        return fastScrollChannelSections;
    }

    @Override
    public int getPositionForSection(int sectionIndex) {
        return fastScrollChannelMapIndex.get(fastScrollChannelSections[sectionIndex]);
    }

    @Override
    public int getSectionForPosition(int position) {
        return 0;
    }

0 个答案:

没有答案