プログレスバーのグラデーションの色を変更したいと思います。今は単色に変更できますが、グラデーションカラーに変更することはできません。Androidの変更シェイプの描画可能な色
LayerDrawable progressDrawable = (LayerDrawable) myProgressBar.getProgressDrawable();
// get the color drawable of the progress bar
Drawable primaryColor = progressDrawable.getDrawable(1);
// set the new color.
primaryColor.setColorFilter(ContextCompat.getColor(getContext(), R.color.yellow), PorterDuff.Mode.SRC_OVER);
グラディエントカラーの代わりに、グラデーションカラーを変更したいと思います。
EDITマイDrawableのファイル
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="@color/gray300"
android:centerColor="@color/gray400"
android:centerY="0.75"
android:endColor="@color/gray500"
android:angle="270"
/>
</shape>
</item>
<item
android:id="@+id/progress">
<clip>
<shape>
<corners
android:radius="5dip" />
**I want to change this gradient color**
<gradient
android:startColor="#33FF33"
android:endColor="#008000"
android:angle="270" />
</shape>
</clip>
</item>
</layer-list>
私はエラー 'android.graphics.drawable.LayerDrawableがandroid.graphics.drawable.GradientDrawable'にキャストすることはできませんを取得しています。私はdrawableファイルでインクルードしました。 –
editted my answers – ZeroOne