I have noticed in the devices of higher versions, the background color of options menu is default set to black. I need to change it to white, as well as the text color to black.
I had googled for it and found many answers, but none of them seemed useful to me yet.
The suggestion I tried is adding this in my onCreateOptionsMenu:
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 .setBackgroundColor(Color.BLACK);
// set the text color
((TextView) view).setTextColor(Color.WHITE);
}
});
return view;
} catch (InflateException e) {
} catch (ClassNotFoundException e) {
}
}
return null;
}
});
return super.onCreateOptionsMenu(menu);
But, it didn't help me out.