How to put a logo on Toolbar?

Asked

Viewed 1,762 times

6

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

How do I place a company’s logo on Toolbar?

1 answer

10


A simple way to do this is to create a Toolbar custom and insert a ImageView logo. See in this case below, I put a logo in the center of the toolbar. Not to create in it view, you can use a separate XML, for example toolbar.xml and include in its main.xml using the tag <include>. Behold:

<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>

This way you can include your Toolbar in his main.xml. Behold:

<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>

See the result image:

inserir a descrição da imagem aqui

  • In the background I put an image then?

  • 1

    Ah , now I understand , thank you brother !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.