Change the actionbar homeAsUpIndicator Programmatically

后端 未结 12 1600
甜味超标
甜味超标 2020-12-09 23:08

I used the following hack to change the homeAsupIndicator programmatically.

int upId = Resources.getSystem().getIdentifier(\"up\", \"id\", \"android\");
if (         


        
12条回答
  •  Happy的楠姐
    2020-12-09 23:24

    You can try this:

    this.getSupportActionBar().setHomeAsUpIndicator( R.drawable.actionbar_indicator ); //for ActionBarCompat
    this.getActionBar().setHomeAsUpIndicator( R.drawable.actionbar_indicator ); //for default actionbar for post 3.0 devices
    

    If you need change the position of the icon, you must create a drawable file containing a "layer-list" like this:

    actionbar_indicator.xml

    
    
        
    
    

提交回复
热议问题