1
私はSeekBar
を使用していますが、別の色を使用する必要がありますSeekBar
の進捗状況。drawable xml形の色が真似る
だから私は、これはdrawaleのxmlですプログラムで
描画可能形状の色を変更する必要があります。 seekbar_points.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@android:id/background"
android:drawable="@drawable/points_bg" />
<item android:id="@android:id/progress">
<clip android:drawable="@drawable/points_progress" />
</item>
</layer-list>
points_progress.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke android:width="6dp" android:color="@color/colorAccent" />
</shape>
points_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke android:width="6dp" android:color="@color/color7" />
</shape>
私は動的にこの緑の色領域を変更する必要があります。
seekBar.getProgressDrawable().setColorFilter(ContextCompat.getColor(сontext, R.color.color_new), PorterDuff.Mode.SRC_IN);
更新:
場合は、このために私は
私はクラスキャストを持っていますここの例外 – CarinaMj
seekbar.getProgressDrawable()は 'X extends Drawable'を返します。返された特定のクラスを投稿することはできますか? – DeKaNszn
@CarinaMjあなたの状況に合わせてシンプルなコードに変更しました – DeKaNszn