AlphabetSideBar¶
Quick start¶
<com.ave.vastgui.tools.view.alphabetsidebar.AlphabetSideBar
android:id="@+id/alphabetsidebar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
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" />
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" />
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" />
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" />
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" />
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 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" />
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")
}
})