I create an app with custom ActioBar. It works, but not on all devices. On Lenovo k990 it is not correct. - I am sorry - Lenovo k900
It should look like this
First variant
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 variant
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 variant
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?