简体   繁体   中英

How to enforce action bar settings icon at old android APIs

The new android smartphones have no menu settings button. Instead, the settings icon is in the ActionBar.

If I run my app on an old smartphone, there is no settings icon in the actionbar. You have to click at the menu settings button of the smartphone.

How can I enforce at older smartphones (APIs) that the settings icon is also in the ActionBar?

What you describe is actually intended by design as per the Backwards compatibility section of the Android Design Guide.

Android phones with traditional navigation hardware keys don't display the virtual navigation bar at the bottom of the screen. Instead, the action overflow is available from the menu hardware key

A quote from a previous answer explains why you shouldn't be concerned with this behaviour:

Ultimately it's more important to the user experience that your app behave consistently with every other app on the same device, than that it behave consistently with itself across all devices. - (source)

However, if you are still adamant you wish to see the same UI across all devices you can consider the following:

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/menu_overflow"
        android:icon="@drawable/overflow_image"
        android:orderInCategory="11111"
        android:showAsAction="always">
        <menu>
            <item
                android:id="@+id/settings_item"
                android:showAsAction="never"
                android:title="@string/settings"/>
        </menu>
    </item>  
</menu>

This example would use a drawable resource overflow_image , as the 'three dots' and always show on the toolbar and behave as you require. You would just need to source the correct drawable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM