Skip to content

AlphabetSideBar

Version 0.5.4

Quick start

Version 0.5.4

<com.ave.vastgui.tools.view.alphabetsidebar.AlphabetSideBar
    android:id="@+id/alphabetsidebar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Default style

Location

Add: Version 0.5.4

Currently supports left and right . It can be set by alphabetsidebar_location or calling setLocation.

mBinding.alphabetsidebar.setLocation(AlphabetSideBar.LEFT)
<com.ave.vastgui.tools.view.alphabetsidebar.AlphabetSideBar
    ...
    app:alphabetsidebar_location="left" />
![Location left](../img/location_left.jpg){ width="220" } ![Location right](../img/location_right.jpg){ width="220" }

Background color

Add: Version 0.5.4   Update: Version 1.5.2

Background color can be set by alphabetsidebar_background or calling barBackgroundColor .

binding.alphabetsidebar.barBackgroundColor = ...
<com.ave.vastgui.tools.view.alphabetsidebar.AlphabetSideBar
    ...
    app:alphabetsidebar_background="#26B2BEC3" />
![Background](../img/background.jpg){ width="220" }

Bar text size

Add: Version 0.5.4   Update: Version 1.5.2

Bar text size can be set by alphabetsidebar_text_size or calling barTextSize .

binding.alphabetsidebar.barTextSize = 20f.SP
<com.ave.vastgui.tools.view.alphabetsidebar.AlphabetSideBar
    ...
    app:alphabetsidebar_text_size="20sp" />
![Text size](../img/text_size.jpg){ width="220" }

Bar text color

Add: Version 0.5.4   Update: Version 1.5.2

Bar text color can be set by alphabetsidebar_text_color or calling barTextColor .

binding.alphabetsidebar.barTextColor = ...
<com.ave.vastgui.tools.view.alphabetsidebar.AlphabetSideBar
    ...
    app:alphabetsidebar_text_color="#e17055" />
![Text color](../img/text_color.jpg){ width="220" }

Indicator text color

Add: Version 0.5.4   Update: Version 1.5.2

Indicator text color can be set by alphabetsidebar_indicator_text_color or calling barIndicatorTextColor .

The left is the default color, and the right is the modified color.

binding.alphabetsidebar.barIndicatorTextColor = ...
<com.ave.vastgui.tools.view.alphabetsidebar.AlphabetSideBar
    ...
    app:alphabetsidebar_indicator_text_color="#0984e3" />
![Indicator text default color](../img/indicator_text_default_color.jpg){ width="150" } ![Indicator text color](../img/indicator_text_color.jpg){ width="150" }

Bubble text size

Add: Version 0.5.4   Update: Version 1.5.2

Bubble text size can be set by alphabetsidebar_bubble_text_size or calling bubbleTextSize .

The left is the default size and the right is the modified size.

binding.alphabetsidebar.bubbleTextSize = 35f.SP
<com.ave.vastgui.tools.view.alphabetsidebar.AlphabetSideBar
    ...
    app:alphabetsidebar_bubble_text_size="35sp" />
![Bubble text default size](../img/bubble_text_default_size.jpg){ width="270" } ![Bubble text size](../img/bubble_text_size.jpg){ width="270" }

Bubble text color

Add: Version 0.5.4   Update: Version 1.5.2

Bubble text color can be set by alphabetsidebar_bubble_text_color or calling bubbleTextColor .

The left is the default color, and the right is the modified color.

binding.alphabetsidebar.bubbleTextColor = ...
<com.ave.vastgui.tools.view.alphabetsidebar.AlphabetSideBar
    ...
    app:alphabetsidebar_bubble_text_color="#4a69bd" />
![Bubble text default color](../img/bubble_text_default_color.jpg){ width="270" } ![Bubble text default color](../img/bubble_text_color.jpg){ width="270" }

Register listener

Add: Version 0.5.4

binding.alphabetsidebar.setLetterListener(object : AlphabetSideBar.LetterListener {
    override fun onIndicatorLetterUpdate(letter: String, index: Int, target: Int) {
        binding.recyclerView.smoothScrollToPosition(target)
    }
})

Update indicator letter target index

Add: Version 0.5.4

By calling setIndicatorLetterTargetIndex, you can update the target index value of the letter, which will be stored in AlphabetSp .

binding.alphabetsidebar.setIndicatorLetterTargetIndex("A", target)

Through the onIndicatorLetterTargetUpdate of LetterListener ,you can observe the update.

binding.alphabetsidebar.setLetterListener(object : AlphabetSideBar.LetterListener {
    ... // onIndicatorLetterUpdate implemention

    override fun onIndicatorLetterTargetUpdate(letter: String, target: Int) {
        logger.d(tag = "Gtest", "$letter target index is $target")
    }
})

Sample code

Sample code