Display action bar menu button

2019-02-17 00:58发布

Is there any possible way to display the three dots menu in action bar on divices with hardware menu button? Like Samsung Galaxy etc.

标签: android menu
4条回答
叼着烟拽天下
2楼-- · 2019-02-17 01:16

In my app I have nested menu like:

//menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/three_dots_item"
      android:icon="@drawable/ic_three_dots"
      android:title="@string/title"
      android:showAsAction="always">
      <menu>
        <!-- items to show -->
      </menu>
</item>

</menu>

It's not real overflow, but it's a simple workaround.

查看更多
在下西门庆
3楼-- · 2019-02-17 01:19

The guide says:

Menu items that are not promoted to an action item are available in the overflow menu, revealed by either the device Menu button (when available) or by an "overflow menu" button in the action bar (when the device does not include a Menu button).

查看更多
Rolldiameter
4楼-- · 2019-02-17 01:32

Looks like your answer is at the link below. There's an explanation of why you wouldn't want to do it, and another answer providing a hack to do it anyway (on android 4.x devices).

How to force use of overflow menu on devices with menu button

查看更多
Root(大扎)
5楼-- · 2019-02-17 01:32

This is worked for me

Use

 <uses-sdk
    android:minSdkVersion="8"
    />

instead of

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17"/>

in manifest xml

查看更多
登录 后发表回答