简体   繁体   中英

how to change background color of menu using ActionBarSherlock

I am trying to change the background color of my menu and still get the same result. I want to set my menu to white background. my menu looks like that

<item

    android:id="@+id/exit"
    android:icon="@drawable/exit"
    android:orderInCategory="1"
    android:title="exit">
</item>

<item
    android:id="@+id/about"
    android:icon="@drawable/get_info"
    android:title="about">
</item>

and my style looks like that

<resources>

    <style name="AppTheme" parent="android:Theme.Light" />

</resources>

and the code is:

public boolean onCreateOptionsMenu(Menu menu) {
    getSupportMenuInflater().inflate(R.menu.menu, menu);
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.submenu, menu);
    return super.onCreateOptionsMenu(menu);
}

and I want that my menu background will be white and not as default of android style.

change the actionBar background like this:

View actionBarView = getLayoutInflater().inflate(R.layout.action_bar_custom_view, null);
        actionBar.setCustomView(actionBarView);
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM