将home / homeasup和action菜单置于appcompat操作栏中

时间:2016-01-14 23:41:43

标签: android-layout android-actionbar android-appcompat

好像我是唯一一个有这样问题的人。为什么,android,为什么?... 看看图像。只有标题居中(phew)。另外两项......帮助!

enter image description here

这是相关的xml mojo

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"                       
android:id="@+id/dl_base"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<android.support.design.widget.CoordinatorLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false"
    tools:context="com.farmdog.farmdog.HelperActivity">

    <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:paddingTop="@dimen/appbar_padding_topbottom"
            android:paddingBottom="@dimen/appbar_padding_topbottom"/>
    </android.support.design.widget.AppBarLayout>

和样式:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <!-- colorPrimaryDark wont work on API level < 21 -->
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@color/mainBkgndHard</item>
    <item name="android:textColor">@color/appTextColor</item>
    <item name="android:buttonStyle">@style/ButtonTheme</item>
    <!-- attempt taking actionbar shadow away -->
    <item name="elevation">0dp</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="actionMenuTextColor">@color/appTextColor</item>
    <item name="titleTextColor">@color/appTextColor</item>
    <item name="colorControlNormal">@color/appTextColor</item>
    <item name="android:layout_centerVertical">true</item>
</style>




<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="colorPrimary">@color/colorActionBar</item>
</style>

1 个答案:

答案 0 :(得分:1)

您已设置工具栏paddingTop和paddingBottom。你应该删除它们。我希望这有助于解决您的问题。