showAsAction = “always” is ignored in Toolbar

ぐ巨炮叔叔 提交于 2019-11-29 11:01:48

Replace android:showAsAction with app:showAsAction. You will also need to add xmlns:app="http://schemas.android.com/apk/res-auto" alongside your existing xmlns item in your root element.

With AppCompat there is a little change. If you are running lint it will complain about it. Type this:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto">
<item
    android:id="@+id/someId"
    android:title="@string/someText"
    app:showAsAction="always"/>
</menu>

You need to declare the "app" namespace and reference it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!