我从谷歌关于动作栏的样式背景的本教程 https://developer.android.com/training/basics/actionbar/styling.html 但是当我实现分割操作栏时,顶部操作栏的背景会改变,但是底部操作栏没有。
https://dl.dropboxusercontent.com/u/37599516/Untitled.png
有什么想法吗?
答案 0 :(得分:0)
底部的菜单显示不是操作栏,其选项菜单。您必须为选项菜单设置样式。可能会对您有所帮助
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.my_menu, menu);
getLayoutInflater().setFactory(new Factory() {
@Override
public View onCreateView(String name, Context context,
AttributeSet attrs) {
if (name .equalsIgnoreCase(“com.android.internal.view.menu.IconMenuItemView”)) {
try {
LayoutInflater f = getLayoutInflater();
final View view = f.createView(name, null, attrs);
new Handler().post(new Runnable() {
public void run() {
// set the background drawable
view .setBackgroundResource(R.drawable.my_ac_menu_background);
// set the text color
((TextView) view).setTextColor(Color.WHITE);
}
});
return view;
} catch (InflateException e) {
} catch (ClassNotFoundException e) {
}
}
return null;
}
});
return super.onCreateOptionsMenu(menu);
}