Toolbar toolbar =(Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<!--自定义控件-->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="栗子便签"
android:textColor="#ffffff"
android:textSize="20dp" />
</android.support.v7.widget.Toolbar>