Toolbar修改字体颜色与添加返回键

来源:互联网 发布:漫画控无网络连接 编辑:程序博客网 时间:2024/06/05 03:26

1.布局中添加toolbar:

<?xml version="1.0" encoding="utf-8"?><android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    android:id="@+id/toolbar"    android:layout_width="match_parent"    android:background="?attr/colorPrimary"    android:layout_height="wrap_content"    android:fitsSystemWindows="true"    android:titleTextColor="?attr/colorPrimary"    app:title="Toolbar"    app:titleTextColor="#ffffff"    app:theme="@style/ToolbarTheme"//通过主题改变返回键颜色    android:minHeight="?attr/actionBarSize"></android.support.v7.widget.Toolbar>

ToolbarTheme:

<style name="ToolbarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">        <item name="colorControlNormal">#ffffff</item>    </style>

2.代码中设置显示返回键:

 setSupportActionBar(mToolbar);            //设置是否有返回箭头            getSupportActionBar().setDisplayHomeAsUpEnabled(true);            //设置标题文字            mToolbar.setTitle("mToolbar");
阅读全文
0 0