2015-09-23 77 views
1

我想刪除我的動作欄溢出菜單週圍的陰影,但我還沒有找到任何允許的屬性。我正在擴展Theme.AppCompat。 Android動作欄溢出菜單刪除陰影

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat"> 
    <!-- Customize your theme here. --> 
    <item name="actionOverflowButtonStyle">@style/OverflowButton</item> 
    <item name="actionOverflowMenuStyle">@style/OverflowMenu</item> 
    <item name="actionBarStyle">@style/MyActionBarLogo</item> 
    <item name="android:dropDownListViewStyle">@style/PopupMenuListView</item> 
    <item name="dropDownListViewStyle">@style/PopupMenuListView</item> 
    <item name="android:textColor">@color/black</item> 
    <item name="android:popupMenuStyle">@style/PopupMenu</item> 
</style> 
<style name="MyActionBarLogo" parent="Widget.AppCompat.ActionBar"> 
    <item name="background">@color/white</item> 
    <item name="displayOptions">useLogo|showHome</item> 

    <item name="elevation">0dp</item> 
    <item name="android:windowContentOverlay">@null</item> 
</style> 
<style name="OverflowButton" parent="@style/Widget.AppCompat.ActionButton.Overflow"> 
    <item name="android:src">@mipmap/menu_logo</item> 
</style> 
<style name="OverflowMenu" parent="@style/Widget.AppCompat.PopupMenu.Overflow"> 
    <item name="overlapAnchor">false</item> 
    <item name="android:dropDownVerticalOffset">52dp</item> 
    <item name="android:dropDownHorizontalOffset">10dp</item> 
</style> 
<style name="PopupMenuListView" parent="@style/Widget.AppCompat.ListView.DropDown"> 
    <item name="android:divider">@drawable/menu_divider</item> 
    <item name="android:dividerHeight">1dp</item> 
    <item name="android:textColor">@color/black</item> 
    <item name="android:background">@color/white</item> 
</style> 
<style name="PopupMenu" parent="@style/Widget.AppCompat.ListPopupWindow"> 
    <item name="android:popupBackground">@color/white</item> 
</style> 

http://imgur.com/5mbceT9

回答

1

您可以嘗試的解決方案this

getSupportActionBar().setElevation(0); 

UPDATE

<style name="MyActionBarLogo" parent="Widget.AppCompat.ActionBar"> 
    <item name="background">@color/white</item> 
    <item name="displayOptions">useLogo|showHome</item> 

    <item name="elevation">0dp</item> 
    <item name="android:windowContentOverlay">@null</item> 
    <item name="android:actionDropDownStyle">@style/DropDownMenuStyle</item> 
</style> 



<style name="DropDownMenuStyle" parent="Widget.AppCompat.Spinner.DropDown.ActionBar"> 
    <item name="android:background">@android:color/transparent</item> 
</style> 
+0

那只是對動作條的影子,我已經刪除:) – tomek550

+0

好難過,我會更新我的答案 – NaviRamyle

+0

無法解析符號'@ style/Widget.Spinner.DropDown.ActionBar', 我已經在那裏添加了AppCompat,所以它現在是@ ​​style/Widget.AppCompat.Spinner.DropDown.ActionBar,但是陰影仍然存在。 – tomek550

0

您需要將零高程樣式應用於正確的元素,在本例中爲actionOverflowMenuStyle。

(這是使用程序兼容性)

<style name="Theme.myapp" parent="Theme.AppCompat.Light"> 
    <item name="actionOverflowMenuStyle">@style/Theme.myapp.Widget.PopupMenu.Overflow</item> 
</style> 

然後

<style name="Theme.myapp.Widget.PopupMenu.Overflow" parent="Widget.AppCompat.PopupMenu.Overflow"> 
    <item name="elevation">0dp</item> 
    <item name="android:popupElevation">0dp</item> 
</style>