我一直试图为支持API 15的应用程序着色ProgressBar drawable。我也需要动态地执行它。这是我到目前为止所尝试的内容:
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true" />
Drawable drawable = DrawableCompat.wrap(progressBarSync.getIndeterminateDrawable());
DrawableCompat.setTint(drawable, colorVibrantDark);
// wrap using DrawableCompat
Drawable drawable = DrawableCompat.wrap(progressBarSync.getIndeterminateDrawable());
// don't wrap using DrawableCompat :/
Drawable indeterminateDrawable = progressBarSync.getIndeterminateDrawable();
// set the tint for wrapped drawable
DrawableCompat.setTint(drawable, colorVibrantDark);
// change the color filter as well for the wrapped drawable
drawable.setColorFilter(colorVibrantDark,
PorterDuff.Mode.SRC_IN);
// set the tint for the NOT wrapped drawable
DrawableCompat.setTint(indeterminateDrawable, colorVibrantDark);
// change the color filter as well for the NOT wrapped drawable
indeterminateDrawable.setColorFilter(colorVibrantDark,
PorterDuff.Mode.SRC_IN);
感谢任何帮助/建议。
由于