---
# System prepended metadata

title: Customize a toolbar

---

# Customize a toolbar

1. Create XML resource name 'custom_action_bar.xml'

```xml=
<?xml version = "1.0" encoding = "utf-8"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
    xmlns:app = "http://schemas.android.com/apk/res-auto"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/my_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimaryDark"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:id="@+id/my_toolbar_title1"
                android:gravity="center"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="TEST 111"/>

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:src="@drawable/ic_launcher_foreground"/>

        </LinearLayout>

    </androidx.appcompat.widget.Toolbar>

</LinearLayout>
```

2. Add this in activity_main.xml file

```xml=
<!-- Load the toolbar here --> 
<include layout="@layout/custom_action_bar" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"/> 
```


