Android工具栏对齐问题

时间:2015-04-19 04:46:28

标签: android android-layout android-support-library android-toolbar

即使我的工具栏中没有副标题,标题也会转移到顶部。如何将其与导航图标对齐?

<android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            app:navigationIcon="@drawable/abc_ic_ab_back_mtrl_am_alpha"
            android:gravity="top"
            app:title="Hello title"
            android:background="@drawable/citylook"/>

Issue image

2 个答案:

答案 0 :(得分:0)

您应该为工具栏分配minHeight

<android.support.v7.widget.Toolbar 
    android:minHeight="?attr/actionBarSize">

答案 1 :(得分:0)

我最近遇到了类似的问题并设法找到解决方案。我希望也能解决你的问题。我只是在此处粘贴链接,因为我懒惰:Android Toolbar: title and overflow menus aligment issue on 5.0 only 基本上,如果您在Lollipop设备上启动应用程序,则无需设置没有ActionBar的Activity并将其替换为工具栏:您必须为Lollipop和Lollipop设备编写不同的主题和布局。 现在让我,如果这对你有用!