How to put a logo on the Toolbar?

6

I was searching here and found something very interesting, the company logo on Toolbar .

How do I put a company logo on Toolbar ?

    
asked by anonymous 28.03.2017 / 21:08

1 answer

10

A simple way to do this is to create a% custom% and enter a Toolbar with the logo. See in this case below, I placed a logo in the center of the toolbar. To not create in the same view , you can use a separate XML such as ImageView and include in your toolbar.xml using the tag main.xml . See:

<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/wld_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center">

        <ImageView
            android:layout_width="100dp"
            android:layout_height="50dp"
            android:src="@drawable/creative" />
    </LinearLayout>

</android.support.v7.widget.Toolbar>

In this way, you can include your <include> in your Toolbar . See:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <include layout="@layout/toolbar"/>

</LinearLayout>

View the result image:

    
28.03.2017 / 21:22