SetColorFilter is not working in Xamarin.Android

Viewed 2329
var upArrow = Resources.GetDrawable(Resource.Drawable.abc_ic_ab_back_material);
upArrow.SetColorFilter(Resources.GetColor(Android.Resource.Color.White), PorterDuff.Mode.SrcIn);
SupportActionBar.SetHomeAsUpIndicator(upArrow);

The above code does not change the arrow color. upArrow ColorFilter value is null. What should be the reason for this? I'm not asking how to change the drawable color. My question is why the above code fails to set the color filter? Following is the MainActivity code.

public class MvxFormsApplicationActivity : FormsAppCompatActivity
{
    protected override void OnCreate(Bundle bundle)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;
        base.OnCreate(bundle);

        Xamarin.Forms.Forms.Init(this, bundle); ;
        //Plugins.NewictLib.Forms.Android.Renderers.GifImageViewRenderer.Init ();
        DLToolkit.Forms.Controls.FlowListView.Init ();
        UserDialogs.Init ((Activity) Xamarin.Forms.Forms.Context);

        OxyPlot.Xamarin.Forms.Platform.Android.PlotViewRenderer.Init();

        //            var mvxFormsApp = new MvxFormsApp ();
        //            LoadApplication (mvxFormsApp);
        var myApp = new MyFormsApp();
        LoadApplication (myApp );
        AppCompatDelegate.CompatVectorFromResourcesEnabled = true;
        //the following needs to set so that the back button color can be changed
        var upArrow = Resources.GetDrawable(Resource.Drawable.abc_ic_ab_back_material);
        upArrow.SetColorFilter(Resources.GetColor(Android.Resource.Color.White), PorterDuff.Mode.SrcIn);
        SupportActionBar.SetHomeAsUpIndicator(upArrow);

               if (IsPlayServicesAvailable())
        {
            var intent = new Intent(this, typeof(RegistrationIntentService));
            StartService(intent);
        }
        //var presenter = Mvx.Resolve<IMvxViewPresenter>() as MvxFormsDroidMasterDetailPagePresenter;
        var presenter = Mvx.Resolve <IMvxViewPresenter> () as MVxFormsDroidCustomPagePresenter;//MvxFormsDroidPagePresenter;
        if ( presenter == null ) {
            throw new ArgumentNullException (nameof(presenter), "MvxFormsApplicationActivity: Please check your Activity class and ensure the presenter has value");
        }
        //presenter.MvxFormsApp = mvxFormsApp;
        presenter.MvxFormsApp = oznesFormsApp;
        Mvx.Resolve<IMvxAppStart>().Start();
    }
  }
1 Answers
Related