如何在菜单顶部显示工具栏的标题

问题描述 投票:0回答:1

我试图弄清楚如何将工具栏的标题放在菜单的顶部,但是我没有在线找到任何内容。

基本上,我希望在底部的屏幕快照上具有与Google Maps相同的工具栏:their app但目前我只有这个:my app

这是我在工具栏中添加菜单的方式

    toolbar = this.findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.a_menu);
    toolbar.setTitle("Title");

这是我的工具栏的XML

    <androidx.appcompat.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="156dp"
    android:layout_gravity="bottom"
    android:layout_margin="5dp"
    android:animateLayoutChanges="true"
    android:background="#fff"
    android:elevation="8dp"
    android:gravity="top|left"

    ></androidx.appcompat.widget.Toolbar>
android xml menu toolbar
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.