简体   繁体   English

如何在没有操作栏的情况下显示菜单图标?

[英]How to display the menu icon without action bar?

I'm trying to create the following layout:我正在尝试创建以下布局:

在此处输入图像描述

In my layout main_act I have:在我的布局main_act我有:

    <!-- Tool bar -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/primaryColor"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    </LinearLayout>

    <!-- Menu -->

And in Manifest file I have:在清单文件中我有:

        <activity
            android:name=".MainAct"
            android:label="MainAct"
            android:theme="@style/MainAct" />

where the "@style/MainAct" is:其中"@style/MainAct"是:

    <style name="MainAct" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

I want to have no bar in order to use the toolbar so I used parent="Theme.AppCompat.Light.NoActionBar" but it displays the bar anyways with the string MainAct .为了使用工具栏,我希望没有栏,所以我使用了parent="Theme.AppCompat.Light.NoActionBar"但它仍然使用字符串MainAct显示栏。 How can I display the menu icon on the background without the action bar?如何在没有操作栏的情况下在背景上显示菜单图标?

Remove the <androidx.appcompat.widget.Toolbar> tag and add an ImageButton on top left corner with menu icon删除<androidx.appcompat.widget.Toolbar>标签并在左上角添加一个带有菜单图标的 ImageButton

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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