ActionBar three-dot dropdown opens at the wrong pl

2019-07-15 05:52发布

I've implemented an ActionBar with the com.android.support:appcompat-v7:22.1.1 library. Here you can see the code and my question:

ActionBar with appcompat library v7 (ava.lang.IllegalStateException: You need to use a Theme.AppCompat theme)

That works, but I have one last problem. After changing the ActionBar to the new library, the settings dropdown opens into the actionbar and not among it (see image) and the background of the settings dropdown is grey instead of white?

enter image description here

How can I solve that?

1条回答
Luminary・发光体
2楼-- · 2019-07-15 06:13

Answering the first part of your question, the placement/location of the dropdown menu is supposed to be that way according to the Material Design guidelines, so that's not a bug.

Concerning the second part, to change the color of the dropdown menu to white, in styles.xml, add the following lines:

<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:popupMenuStyle">@style/popupMenuStyle</item>
</style>

<style name="popupMenuStyle" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">#FFFFFF</item>
</style>

And in your AndroidManifest.xml, replace:

 android:theme="@style/Theme.AppCompat.Light.DarkActionBar">

with:

 android:theme="@style/AppTheme">
查看更多
登录 后发表回答