AAA
AAA

Reputation: 505

custom popup menu background not working for Theme.AppCompat.Light.DarkActionBar android

i have made a popup menu. now i want to customize its background color. i have followed some tutorial and stackoverflow but nothing working. app base theme is

Theme.AppCompat.Light.DarkActionBar

my style code is:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <!--<item name="android:popupMenuStyle">@style/OptionMenu</item>-->
    <item name="android:itemBackground">#167be1</item>
</style>

<!--<style name="OptionMenu" parent="@style/Theme.AppCompat.Light.DarkActionBar">-->

    <!--<item name="android:popupBackground">#1278ce</item>-->

<!--</style>-->

can anyone please help me on this issue.

Upvotes: 2

Views: 792

Answers (1)

AskNilesh
AskNilesh

Reputation: 69709

Try this

<style name="OptionMenu" parent="@style/Theme.AppCompat.Light.DarkActionBar">

    <item name="android:itemBackground">#21B6D7</item>
    <item name="android:textColor">#FFFFFF</item>

</style>

apply theme to your PopupMenu like this

Context contextWrapper = new ContextThemeWrapper(context, R.style.OptionMenu);
PopupMenu popup = new PopupMenu(contextWrapper, v);

Upvotes: 2

Related Questions