How do I remove the field and app icon in a custom ActionBar?
I am creating an application with a custom ActioBar. It works, but not on all devices. In Lenovo k990, this is not true. - Sorry - Lenovo k900
It should look like this:
First option
ViewGroup actionBarLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.action_bar_category, null);
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(actionBarLayout);
}
Second option
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.action_bar_category);
}
View actionBarLayout = actionBar.getCustomView();
ViewGroup.LayoutParams lp = actionBarLayout.getLayoutParams();
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
actionBarLayout.setLayoutParams(lp);
Third option
ViewGroup actionBarLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.action_bar_main_menu, null);
ActionBar actionBar = getActionBar();
if(actionBar!= null){
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setHomeButtonEnabled(false);
actionBar.setLogo(null);
actionBar.setCustomView(actionBarLayout);
View v = actionBar.getCustomView();
ViewGroup.LayoutParams lp = v.getLayoutParams();
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
v.setLayoutParams(lp);
}
Can you help me?
+3
source to share
No one has answered this question yet
Check out similar questions: