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

时间:2020-05-13 16:38:26

标签: android android-layout

我正在尝试创建以下布局:

enter image description here

在我的布局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 -->

在清单文件中,我有:

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

其中"@style/MainAct"是:

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

我不想使用工具栏来使用工具栏,所以我使用了parent="Theme.AppCompat.Light.NoActionBar",但是无论如何它都显示带有字符串MainAct的工具栏。如何在没有操作栏的情况下在后台显示菜单图标?

1 个答案:

答案 0 :(得分:0)

删除<androidx.appcompat.widget.Toolbar>标签,并在左上角添加带有菜单图标的ImageButton