Toolbar简单用法
一、设置布局文件:
<android.support.v7.widget.Toolbar
android:id="@+id/id_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/main_blue"/>
二、隐藏ActionBar
这里用的办法是修改res/values/styles.xml,使用Theme.AppCompat.Light.NoActionBar或者是Theme.AppCompat.NoActionBar主题,即可去掉ActionBar
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
</style>
</resources>
三、在Activity里调用Toolbar
Toolbar mtoolbar = (Toolbar)findViewById(R.id.id_toolbar);
setSupportActionBar(mtoolbar);