Android Seekbar起点

问题描述 投票:0回答:1

我的搜索栏的范围在(-100,100)之间,并且拇指从0开始(在搜索栏的中间)。我想进度从中间开始。使用此库,进度色总是始于搜索栏的开头。

我使用了这个带有刻度的库。https://github.com/warkiz/IndicatorSeekBar

enter image description here

我的xml。

enter image description here

以及我的Kotlin代码:

mBinding.seekbarWorkout.customSectionTrackColor { colorIntArr ->
            for (i in 0..9) {
                colorIntArr[i] = resources.getColor(R.color.white_transparent, null)
            }

            true //true if apply color , otherwise no change
        }

mBinding.seekbarWorkout.onSeekChangeListener = object : OnSeekChangeListener {
            override fun onSeeking(seekParams: SeekParams?) {}

            override fun onStartTrackingTouch(seekBar: IndicatorSeekBar?) {}
            override fun onStopTrackingTouch(seekBar: IndicatorSeekBar?) {
                updateViewModel()
            }
        }

跟踪进度颜色必须从搜寻栏的中间开始。我想要这样的东西:

enter image description here

android kotlin seekbar android-seekbar seekbar-thumb
1个回答
0
投票

尝试过演示并可以正常工作。

    <com.warkiz.widget.IndicatorSeekBar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:isb_progress="0" // this property is your solution
        app:isb_min="-100"
        app:isb_max="100"
        app:isb_tick_marks_size="3dp"
        app:isb_ticks_count="5" />

对我来说,如果该代码仍然无法正常工作,则可以正常工作,然后实施库并复制那个IndicatorSeekBar类以更好地理解它。

© www.soinside.com 2019 - 2024. All rights reserved.