Android 风格的 SeekBar

Yon*_*Nir 4 android android-styles android-seekbar

我想为我的应用程序创建一个样式Seekbar。我只想改变拇指和酒吧本身的颜色。

我设法像这样更改拇指名称:

<style name="MySeekBar" parent="@style/Widget.AppCompat.SeekBar">
    <item name="android:thumbTint"> @color/turquoise </item>        
 </style>
Run Code Online (Sandbox Code Playgroud)

但我不确定如何更改栏的颜色。我知道如何用代码来做,但不在 xml 中:

seekBar.getProgressDrawable().setColorFilter(getContext().getResources().getColor(R.color.turquoise), Mode.SRC_ATOP);
Run Code Online (Sandbox Code Playgroud)

如何使用 xml 中定义的样式设置颜色过滤器的样式?

小智 6

您可以使用

android:progressTint
Run Code Online (Sandbox Code Playgroud)

更改搜索栏进度部分的颜色和

android:progressBackgroundTint
Run Code Online (Sandbox Code Playgroud)

以您的风格更改栏背景的颜色