I'd like to set the color of a ProgressBar but the tint property appears to be missing.
The documentation suggests that the property is exposed.
https://developer.xamarin.com/api/property/Android.Widget.ProgressBar.ProgressTintList/
I am attempting to replicate the following Java.
mProgressBar.setProgressTintList(ColorStateList.valueOf(Color.argb(255, 0, 128, 0)));
The SetProgressTintList method or the ProgressTintList property appears to be missing.
public class CustomProgressBarRenderer :ProgressBarRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
{
base.OnElementChanged(e);
Control.ProgressDrawable.SetColorFilter(Color.FromRgb(182, 231, 233).ToAndroid(), Android.Graphics.PorterDuff.Mode.SrcIn); Control.ProgressTintList = Android.Content.Res.ColorStateList.ValueOf(Color.FromRgb(182, 231, 233).ToAndroid()); } }
I tried and this working
Answers
public class CustomProgressBarRenderer :ProgressBarRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
{
base.OnElementChanged(e);
I tried and this working
I needed to be compiling with API level 21. Doh!
https://developer.android.com/reference/android/widget/ProgressBar.html#setProgressTintList(android.content.res.ColorStateList)
Is there a way to get this working that will support pre API level 21 on android? It's the usage of
ProgressTintList
that is problematic: https://developer.android.com/reference/android/widget/ProgressBar.html#setProgressTintList(android.content.res.ColorStateList)Answer pre API 21 is: https://forums.xamarin.com/discussion/120361/progressbar-colour-android-api-level-21/p1?new=1