Lollipop Progress Bar Tinting

I’m on a Lollipop device (MotoG 2014), I read about progress bar tinting, but this is not working…I get the default progress bar color. What am I missing here?

<ProgressBar
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:backgroundTintMode="src_in"
    android:indeterminate="true"
    android:indeterminateTint="#f00" />

Many thanks.

  • Is local storage for a Phonegap app on an Android device separate from the built in browser?
  • Avast is reporting that my Android application is a trojan
  • Tablet can't download .apk file in some browsers
  • Why Android is truncating my ActionBar title?
  • How to play native camera sound on Android
  • Android get view of Preference in PreferenceActivity
  • Related posts:

    Help with a custom View attributes inside a Android Library Project
    Android Studio - Gradle Manifest Merging Failed
    How to make a custom grid with images in android ?
    Using Pull to Refresh gridview in viewpager in Activity inside ActivityGroup causes ClassCastExcepti...
    Problems with implementing contextual action mode in recyclerview fragment
    Wake Service directly from AlarmManager
  • Gradle and Android : pom configuration with multiple Maven artifacts publication
  • Android Spinner OnItemSelected not called with the same item
  • Change scrollbar color in Android
  • How to handle multiple fragment interaction listeners in one Activity properly?
  • How can I create a weekly calendar view for an Android Honeycomb application?
  • Android Volley access http response header fields
  • 2 Solutions collect form web for “Lollipop Progress Bar Tinting”

    Try changing your ProgressBar to this

    <ProgressBar
    android:id="@+id/view_progress"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:indeterminate="true"
    android:indeterminateTintMode="src_in"
    android:indeterminateTint="@color/red"
    />
    

    Also you can do it programmaticaly doing this :

    ProgressBar progressBar;
    progressBar = (ProgressBar)findViewById(R.id.view_progress);
    progressBar.getProgressDrawable().setColorFilter(Color.RED, Mode.SRC_IN);
    

    References

    Setting in ProgressBar Tint color

    The accepted solution wasn’t working for me on pre-Lollipop, but I found this solution to fit all APIs and on top of that, it doesn’t use any deprecated code:

    // fixes pre-Lollipop progressBar indeterminateDrawable tinting
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    
        Drawable wrapDrawable = DrawableCompat.wrap(mProgressBar.getIndeterminateDrawable());
        DrawableCompat.setTint(wrapDrawable, ContextCompat.getColor(getContext(), android.R.color.holo_green_light));
        mProgressBar.setIndeterminateDrawable(DrawableCompat.unwrap(wrapDrawable));
    } else {
        mProgressBar.getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(getContext(), android.R.color.holo_green_light), PorterDuff.Mode.SRC_IN);
    }
    

    Happy coding !

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.