新的安卓智能手机没有菜单设置按钮。相反,设置图标位于 ActionBar 中。
如果我在旧智能手机上运行我的应用程序,操作栏中没有设置图标。您必须单击智能手机的菜单设置按钮。
如何在较旧的智能手机 (API) 上强制设置图标也在 ActionBar 中?
最佳答案
您所描述的内容实际上是根据 Backwards compatibility section 设计的 Intent Android 设计指南。
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)
但是,如果您仍然坚持希望在所有设备上看到相同的用户界面,您可以考虑以下几点:
<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
,作为“三点”并始终显示在工具栏上并按您的要求运行。您只需要获取正确的可绘制资源
关于java - 如何在旧的 Android API 上强制执行操作栏设置图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30374746/