这是自定义ActionBar样式的布局(使用的是SherlockActionBar,总体自定义) java
View customView = getLayoutInflater().inflate(R.layout.actionbar_custom_view, null); ActionBarUtil.init(); // ... getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(customView);
实际显示的时候,在4.4.2系统,ActionBar左上角有一块区域不是自定义的布局。在当前Activity的父类或者上述代码前,调用以下代码,则显示正常: android
// 测试发如今4.4系统上,没有该代码,则custom ActionBar左上角有问题 if (getSupportActionBar() != null) { getSupportActionBar().setTitle(""); }
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/actionbar_logo" android:left="@dimen/AbLogoLeftPadding" android:right="@dimen/AbLogoRightPadding" /> </layer-list>