如何在旧 android API 中强制执行操作栏设置图标
How to enforce action bar settings icon at old android APIs
新的 android 智能手机没有菜单设置按钮。相反,设置图标位于 ActionBar 中。
如果我 运行 我的应用程序是在旧智能手机上运行的,操作栏中没有设置图标。您必须单击智能手机的菜单设置按钮。
如何在较旧的智能手机 (API) 上强制设置图标也在 ActionBar 中?
您所描述的内容实际上是设计的,根据Android设计指南的Backwards compatibility section。
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
引用之前的回答解释了为什么您不应该担心这种行为:
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)
但是,如果您仍然坚持希望在所有设备上看到相同的 UI,您可以考虑以下内容:
<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>
此示例将使用可绘制资源 overflow_image
作为 'three dots' 并始终显示在工具栏上并按您的要求运行。您只需要获取正确的 drawable
新的 android 智能手机没有菜单设置按钮。相反,设置图标位于 ActionBar 中。
如果我 运行 我的应用程序是在旧智能手机上运行的,操作栏中没有设置图标。您必须单击智能手机的菜单设置按钮。
如何在较旧的智能手机 (API) 上强制设置图标也在 ActionBar 中?
您所描述的内容实际上是设计的,根据Android设计指南的Backwards compatibility section。
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
引用之前的回答解释了为什么您不应该担心这种行为:
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)
但是,如果您仍然坚持希望在所有设备上看到相同的 UI,您可以考虑以下内容:
<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>
此示例将使用可绘制资源 overflow_image
作为 'three dots' 并始终显示在工具栏上并按您的要求运行。您只需要获取正确的 drawable