答案 0 :(得分:0)
实现该方法的两种方法是在v21使用自定义样式
<style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
<!-- Required for pre-Lollipop. -->
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">-4.0dp</item>
<!-- Required for Lollipop. -->
<item name="android:overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">4.0dp</item>
</style>
或使用android主题
android:theme="@android:style/Theme.Holo.Light"
参考How I can place overflow menu below toolbar instead of overflow menu to overlaps the app bar
答案 1 :(得分:0)
在values/styles.xml
添加OverflowMenu
样式中:
<style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">-4dp</item>
</style>
在values-21/styles.xml
添加OverflowMenu
样式中:
<style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
<item name="android:overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">4dp</item>
</style>
values/styles.xml
主要样式中使用OverflowMenu
样式为actionOverflowMenuStyle
。<强>值/ styles.xml 强>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="actionOverflowMenuStyle">@style/OverflowMenu</item>
</style>
<style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">4.0dp</item>
</style>
</resources>