Android-Seekbar记号颜色无法更改
我使用的是离散seekbar。我想改变记号的颜色。我试着跟着你Android-Seekbar记号颜色无法更改,android,seekbar,Android,Seekbar,我使用的是离散seekbar。我想改变记号的颜色。我试着跟着你 <SeekBar android:id="@+id/seekBar" style="@style/Widget.AppCompat.SeekBar.Discrete" android:layout_width="match_parent" android:layout_height="wrap_
<SeekBar
android:id="@+id/seekBar"
style="@style/Widget.AppCompat.SeekBar.Discrete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:thumbTint="@color/colorPrimary"
android:tickMarkTint="@color/colorAccent"/>
但我无法删除搜索栏中的灰色记号。请帮我做这个
为您的seekbar创建一种样式
<resources>
<style name="SeekBarWithoutSteps" parent="Base.Widget.AppCompat.SeekBar.Discrete">
<item name="tickMark">@null</item>
</style>
</resources>
<SeekBar
android:id="@+id/seekBar"
style="@style/SeekBarWithoutSteps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:thumbTint="@color/colorPrimary"
android:tickMarkTint="@color/colorAccent"/>
@空的
如果要删除灰色记号/球,只需删除样式,然后将您的drawable应用到android:tickMark
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:tickMark="@drawable/drw_bg_tickmark"
android:thumbTint="@color/colorPrimary"
android:tickMarkTint="@color/colorAccent"/>
我们可以通过java编程实现@null吗?请参见kbar.setTickMark(getResources().getDrawable(R.drawable.drw_bg_tickmark));我们可以动态设置记号绘制。这将需要API级别24及以上。感谢Krishan的回答。这也在起作用。但当我尝试用编程的方式设置时,我遇到了一些问题。所以我要和Zain ans一起去。如果你对以下问题有任何想法,请告诉我。如果你对这个问题有任何想法,请告诉我。。
<resources>
<style name="SeekBarWithoutSteps" parent="Base.Widget.AppCompat.SeekBar.Discrete">
<item name="tickMark">@null</item>
</style>
</resources>
<SeekBar
android:id="@+id/seekBar"
style="@style/SeekBarWithoutSteps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:thumbTint="@color/colorPrimary"
android:tickMarkTint="@color/colorAccent"/>
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:tickMark="@drawable/drw_bg_tickmark"
android:thumbTint="@color/colorPrimary"
android:tickMarkTint="@color/colorAccent"/>