Remove default home/up button in action mode

2019-07-25 12:55发布

问题:

I have created custom action mode which visible on long click on list item . There is default back/up button visible in actionMode.

Without change in style.xml , it's possible to remove default action mode back/up button from fragment/activity class.

Kindly help.

回答1:

Use the method: getActionBar().setDisplayHomeAsUpEnabled(false) to remove the home button from the action bar.

Example:

ActionBar actionBar = getActionBar();
if (actionBar != null) {
    actionBar.setHomeButtonEnabled(false); // disable the button
    actionBar.setDisplayHomeAsUpEnabled(false); // remove the left caret
    actionBar.setDisplayShowHomeEnabled(false); // remove the icon
}


回答2:

Try this,

getActionBar().setDisplayHomeAsUpEnabled(false);

OR

getSupportActionBar().setDisplayHomeAsUpEnabled(false);

this may helps you.



回答3:

You can remove action button home up enabled through ::

if you are using support v7 lib then

getSupportActionBar().setDisplayHomeAsUpEnabled(false);

else 

getActionBar().setDisplayHomeAsUpEnabled(false);