简体   繁体   中英

Customizing ActionBarSherlock - disabling back/home button

I'm using custom layout for an action bar, using the following code:

getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(false);
getSupportActionBar().setIcon(android.R.color.transparent);
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setCustomView(R.layout.custom_action_bar);

However, it keeps showing some fragment of the action bar which is not the custom action bar I've created:

在此处输入图片说明

How do I fix this?

It looks like this was enough to get it working (instead of all the lines I quoted in the question details):

getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.custom_action_bar);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM