SeekBar的Accessibility
最近在做公司项目的Accessibility,刚好做到了关于如果自定义seekbar的contentDescription。其实逻辑就是"偷龙转凤"的思想. 意思就是真正执行的Accessibility的是另外一个view,比如说你可以用一个Textview.
主要实现功能如下:
sbDistance ->seekbar
tvTitle -> Textview
sbDistance.accessibilityDelegate = object : View.AccessibilityDelegate() {
override fun onInitializeAccessibilityEvent(host: View, event: AccessibilityEvent) {
super.onInitializeAccessibilityEvent(host, event)
if (event.eventType != AccessibilityEvent.TYPE_VIEW_SELECTED) {
val content=context.getString(R.string.content_description_distance,
distances[sbDistance.progress / 10])
tvTitle.announceForAccessibility(content)
}
}
override fun sendAccessibilityEvent(host: View,