2015-11-08 57 views
2

我通過官方文檔學習android。問題是,android:popupMenuStyle不起作用。我嘗試了一切,我發現這個,就像使用android:actionBarWidgetTheme,但他們沒有解決我的問題。 繼承人我的風格:如何風格android的動作條溢出菜單

<resources xmlns:android="http://schemas.android.com/apk/res/android"> 

    <style name="CustomTheme" parent="@style/Theme.AppCompat.Light"> 
     <item name="android:actionBarStyle">@style/CustomTheme.ActionBar</item> 
     <item name="actionBarStyle">@style/CustomTheme.ActionBar</item> 
     <item name="android:actionOverflowButtonStyle">@style/CustomTheme.ActionBar.ActionOverflowButtonStyle</item> 
     <item name="actionOverflowButtonStyle">@style/CustomTheme.ActionBar.ActionOverflowButtonStyle</item> 
     <item name="android:popupMenuStyle">@style/CustomTheme.ActionBar.PupopMenuStyle</item> 
     <item name="popupMenuStyle">@style/CustomTheme.ActionBar.PupopMenuStyle</item> 
     <item name="android:windowActionBarOverlay">true</item> 
     <item name="windowActionBarOverlay">true</item> 
    </style> 
    <style name="CustomTheme.ActionBar.PupopMenuStyle" parent="@style/Widget.AppCompat.Light.PopupMenu"> 
     <item name="android:popupBackground">@drawable/action_bar_background</item> 
    </style> 
     ... 
    </resources> 

我分SDK是11 我在做什麼錯?

回答

0

好吧,非常感謝scriptedpapersthis post,我發現我應該使用android:dropDownListViewStyle而不是android:popupMenuStyle。 (概念總誤解,太可惜了:)))

現在我的風格是這樣的:

</resources><resources xmlns:android="http://schemas.android.com/apk/res/android"> 

     <style name="CustomTheme" parent="@style/Theme.AppCompat.Light"> 
      <item name="android:actionBarStyle">@style/CustomTheme.ActionBar</item> 
      <item name="actionBarStyle">@style/CustomTheme.ActionBar</item> 
      <item name="android:actionOverflowButtonStyle">@style/CustomTheme.ActionBar.ActionOverflowButtonStyle</item> 
      <item name="actionOverflowButtonStyle">@style/CustomTheme.ActionBar.ActionOverflowButtonStyle</item> 
      <item name="android:dropDownListViewStyle">@style/CustomTheme.ActionBar.DropDownListViewStyle</item> 
      <item name="dropDownListViewStyle">@style/CustomTheme.ActionBar.DropDownListViewStyle</item> 
      <item name="android:windowActionBarOverlay">true</item> 
      <item name="windowActionBarOverlay">true</item> 
     </style> 

     <style name="CustomTheme.ActionBar.DropDownListViewStyle" parent="@style/Widget.AppCompat.Light.ListView.DropDown"> 
      <item name="android:background">@drawable/action_bar_background</item> 
     </style> 
     ... 
    </resources>