Friday, 31 July 2015

android actionbar -- all settings




According to:

http://developer.android.com/intl/ko/reference/android/app/ActionBar.html

intDISPLAY_HOME_AS_UPDisplay the 'home' element such that it appears as an 'up' affordance.
intDISPLAY_SHOW_CUSTOMShow the custom view if one has been set.
intDISPLAY_SHOW_HOMEShow 'home' elements in this action bar, leaving more space for other navigation elements.
intDISPLAY_SHOW_TITLEShow the activity title and subtitle, if present.
intDISPLAY_USE_LOGOUse logo instead of icon if available.

if you want to show title and logo you should:




    getSupportActionBar().setLogo(R.drawable.new_logo);
    Intent intent = getIntent();
    String action = intent.getAction();
    Set<String> categories = intent.getCategories();
    getSupportActionBar().setDisplayOptions(
            ActionBar.DISPLAY_SHOW_HOME |
                    ActionBar.DISPLAY_USE_LOGO |
                    ActionBar.DISPLAY_SHOW_TITLE |
                    ActionBar.DISPLAY_SHOW_CUSTOM    );


ActionBar.DISPLAY_SHOW_HOME is also necessary for showing the logo.

Below can help you to add a back button. It also remove the button for you if it is the main page.
if (action == null || !action.equals("android.intent.action.MAIN")) {
    getSupportActionBar().setDisplayOptions(getSupportActionBar().getDisplayOptions() | ActionBar.DISPLAY_HOME_AS_UP);
}











1 comment: