2014-01-14 2 views
16

親と@androidというカスタムテーマがあります:style/Theme.Holo.Light.DarkActionBar ドロップダウンメニューを白いバージョンに変更したいのですが(画像参照)Holo Lightの白いドロップダウンメニューを持つ暗いアクションバー

私はいくつかの例を見てきましたが、私にはうまくいかなかったのですが、DarkActionBarのドロップダウンメニューを明るいバージョンで上書きすることは可能ですか?

(私はシャーロックのアクションバーを使用してはいけない)

enter image description here

+0

私はちょうどhttp://jgilfelt.github.io/android-actionbarstylegenerator/ – Broak

+0

[この記事をチェックアウトhttp://stackoverflow.com/questions/16878662/how-to-set-これを使用する傾向がありますアンドロイドポップアップメニューからホワイトへの背景](http://stackoverflow.com/questions/16878662/how-to-set-the-background-of-android-popupmenu-to-white)私はそれを考える同じ問題です。 – JoeyPhillips

答えて

20

これは私のために働きました。それは助けを願って:

<style name="YOUR_DARK_AB_THEME"> 
    <item name="android:actionBarWidgetTheme">@style/YourActionBarWidget</item> 
</style> 

<!-- This helps the PopupMenu stick with Light theme while the ActionBar is in Dark theme --> 
<style name="YourActionBarWidget" 
    parent="android:Theme.Holo.Light"> 
    <item name="android:popupMenuStyle">@android:style/Widget.Holo.Light.PopupMenu</item> 
    <item name="android:dropDownListViewStyle">@android:style/Widget.Holo.Light.ListView.DropDown</item> 
</style> 
+1

完全に動作します。 –

+7

これはLight.DarkActionbarで動作しない可能性がありますか?私は暗いドロップダウンを続けています。 - デフォルトの暗さでも動作しないようです。おそらく私はAppCompatを使用しているので –

+0

私はAppCompatを使って作業しています – Leon

1

は(のPopupMenu

actionBar.getThemedContext()

ので、

アクションバーアクションバー=を作成するために、アクションバーの同じコンテキストを使用(ActionBarActivity) getActivity())。getSupportActionBar();
PopupMenu popMenu =新しいPopupMenu(actionBar.getThemedContext()、anyView);

関連する問題