진행률 막대의 그라디언트 색상을 변경하고 싶습니다. 지금은 단색으로 바꿀 수 있지만 그래디언트 색상으로 바꿀 수는 없습니다.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);
단색 대신 그라디언트 색상을 변경하고 싶습니다.
편집 내 그리기 파일
<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' 캐스트 할 수없는 무엇입니까. 드로어 블 파일로 포함 시켰습니다. –
내 답변 – ZeroOne