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.