【问题标题】:How to remove settings in the toolbar?如何删除工具栏中的设置?
【发布时间】:2018-10-17 14:40:46
【问题描述】:

我只想删除设置点而不影响工具栏中的其他属性。 我可以在这里做什么是我清单的一部分:

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.AppBarOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main_met_calc" />

【问题讨论】:

  • 你是指三个点吗?

标签: android settings toolbar


【解决方案1】:

最简单的方法是删除菜单创建,通过空覆盖 onCreateOptionsMenu:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    return true;
}

【讨论】:

    【解决方案2】:

    只需删除 menu.xml 中的第一个条目

    menu.xml的路径是app/src/main/res/menu

    项目 xml 将如下所示

    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:showAsAction="never"
        android:title="@string/action_settings"/>
    

    【讨论】:

    • 非常感谢:它有效! - 在我删除了选项菜单中的 id action_settings 之后。
    • @blg 我很高兴它帮助了你,那么你能把它标记为答案吗?
    【解决方案3】:

    menu.xml的路径是app/src/main/res/menu

    删除下面的代码

    <item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    android:showAsAction="never"
    android:title="@string/action_settings"/>
    

    【讨论】:

    • 非常感谢:它有效! - 在我删除了选项菜单中的 id action_settings 之后。
    猜你喜欢
    • 2019-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-12
    相关资源
    最近更新 更多