[参考一篇博客进行修改](https://www.kotlintc.com/articles/1974?fr=sidebar)
![13067320-d3ab4cc2fd9c0152.png](https://i-blog.csdnimg.cn/blog_migrate/1ca5b2c1b482ceccf12475a74c6edefa.webp?x-image-process=image/format,png)
添加依赖关系
implementation 'com.android.support:appcompat-v7:23.1.1'
![13067320-ab137d14af7f0fa5.png](https://i-blog.csdnimg.cn/blog_migrate/0d3ed2b9bae512bb31169dea58759571.webp?x-image-process=image/format,png)
更改主题
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
![13067320-c1c28e60fa4641ef.png](https://i-blog.csdnimg.cn/blog_migrate/e14dc03719bc4b30937474dba3319f3d.webp?x-image-process=image/format,png)
布局
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="标题"
android:textSize="20sp" />
</android.support.v7.widget.Toolbar>
</FrameLayout>>
![13067320-3087ef1f64fbc92e.png](https://i-blog.csdnimg.cn/blog_migrate/0dd602bbe53846f1ff319a9e90a17c16.webp?x-image-process=image/format,png)
业务逻辑
toolbar.setLogo(R.mipmap.ic_launcher)
![13067320-190e74108ba5af58.png](https://i-blog.csdnimg.cn/blog_migrate/abfc271e1916e3242ee90bb945f12ac0.webp?x-image-process=image/format,png)
模拟器