0

I have used this code to show homeupbutton in action bar.

getActionBar().setDisplayHomeAsUpEnabled(true);

Now I want this back button to be blue or any other colour that I want. How can I do this programmatically.?

Yawar
  • 1,924
  • 3
  • 29
  • 39

1 Answers1

0

Here it is, to change programmatically the up carret color :

    int upId = getResources().getIdentifier("up", "id", "android");

    if(upId > 0)
    {
        ImageView up = (ImageView) findViewById(upId);
        up.getDrawable().setColorFilter (Color.CYAN, PorterDuff.Mode.SRC_ATOP);
    }

If you are using ABS, add this :

    if (upId == 0) {
        upId = R.id.abs__up;
    }

You might need to do something similar if you use ActionBarCompat.

This code will also change the three lines icon if you are using the navigation drawer !

Stephane Mathis
  • 6,542
  • 6
  • 43
  • 69