Change ActionBar Background Color in code from Navigation List

后端 未结 3 819
予麋鹿
予麋鹿 2020-12-16 06:29

I want to change the color of the Action Bar background when the user chooses a selection in the Navigation List.

Currently, my code looks like this:



        
相关标签:
3条回答
  • 2020-12-16 07:07

    Try this:

    myActivity.invalidateOptionsMenu();
    
    0 讨论(0)
  • 2020-12-16 07:22

    Try using this code:

    ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#ffFEBB31"));
    actionBar.setBackgroundDrawable(colorDrawable); 
    
    0 讨论(0)
  • 2020-12-16 07:26

    I was having this same problem.

    For Xamarin Users in Visual Studio or the like.

    Please paste this just after the SetContentView(Resource.Layou...... in the activity class.

    // Setting ActionBar (Toolbar) background color natively var actionBar = this.ActionBar; actionBar.SetBackgroundDrawable(new ColorDrawable(Color.Black));

    You may change it as you deem necessary of do more on the actionBar variable.

    Thanks hope this helps.

    0 讨论(0)
提交回复
热议问题