しばらくの間、試してみてください。
水平プログレスバーindeterminateDrawable 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">
<shape>
<corners android:radius="2dip" />
<gradient
android:startColor="@color/background_grey"
android:endColor="@color/light_grey"
android:angle="270"
/>
</shape>
</item>
<item
android:id="@android:id/progress"
>
<clip>
<shape>
<corners
android:radius="2dip" />
<gradient
android:startColor="@color/blue"
android:endColor="@color/blue"
android:angle="270" />
</shape>
</clip>
</item>
</layer-list>
コード:
プログレスたpB =(プログレス)v.findViewById(R.id.activation_progressBar)。
if (pB != null) {
if (pB.getIndeterminateDrawable() != null) {
//Getting the progress element from the indeterminate progress drawable and setting it to the custom color specified.
final LayerDrawable indeterminateDrawable = (LayerDrawable) pB.getIndeterminateDrawable();
indeterminateDrawable.getDrawable(1).setColorFilter(CUSTOM_DEFINED, PorterDuff.Mode.SRC_IN);
}
}