安卓toolbar的标题名字,跑到手机屏幕的中间去了,我设置的高度明明是wrap

图片说明
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:theme="@style/AppTheme.AppBarOverlay"
/>
android:id="@+id/fg"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:menu="@menu/nav_menu"
    app:headerLayout="@layout/nav_header"
    />

 这是主布局的。
fun inittoolbar(){
    var toolbar:Toolbar=findViewById(R.id.toolbar)
    toolbar.setTitle("干货")
   // toolbar.setTitleTextColor(ContextCompat.getColor(this,R.color.black))
    setSupportActionBar(toolbar)
    var actionbar=supportActionBar
    if(actionbar!=null){
        actionbar.setDisplayHomeAsUpEnabled(true)
        actionbar.setHomeAsUpIndicator(R.drawable.ic_menu)

    }
}
 这是在mainactivity中声明的。

图片说明
这是相关的style.

https://blog.csdn.net/cocochenqiuyue/article/details/53813163

xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimaryDark"
android:focusable="true"
android:focusableInTouchMode="true"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >

    试试我这个