首页 > 解决方案 > 在 Seekbar 中使用 secondaryProgressTint 的目的是什么?

问题描述

<SeekBar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:max="200"
    android:progress="50"
    android:progressTint="#f00"
    android:secondaryProgressTint="#ffff00"/>

我看到了这种SeekBar支持secondaryProgressTint,但在我设置它之后,它不会影响任何东西(在 Pixel 4XL 和三星 J7 上测试之后)。
此属性是否对某些设备或某些操作步骤有影响?

标签: android

解决方案


secondaryProgressTint defines color for secondary progress in android seekbar.

for example

enter image description here

Find more from the ProgressBar documentation listed here: http://developer.android.com/reference/android/widget/ProgressBar.html#attr_android:secondaryProgress.

In ProgressBar to show secondary progress, first define color for secondary progress by setting secondaryProgressTint attribute to the desired color.

<item name="android:secondaryProgressTint">#ffad00</item>

Then secondary secondaryProgress with secondary progress value using setSecondaryProgress(50);.

Then progress bar will be shown like this:

enter image description here


推荐阅读