android设置toolbar(相当于标题栏)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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:background="#ff000000"
    tools:context=".view.USBCameraActivity"
    tools:ignore="MergeRootFrame">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:navigationIcon="@null"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
  •   在代码中设置 setSupportActionBar(mToolbar);
  •  mToolBar 
    //    @BindView(R.id.toolbar)
    // public Toolbar mToolbar;
  • 可能需要Activity集成Theme.NoActionBar(待验证)

posted on 2018-11-16 09:36  endian11  阅读(491)  评论(0编辑  收藏  举报

导航