Following the suggestion g give by @brightstar, I would like to continue with a further answer.
The best way to control the size and location of the logo on the new toolbar is to not actually use it. The concept is completely different, you need to create a toolbar from scratch. Therefore, you need to make a decision, either you use the layout specified by the actionBar, or include everything new, including the title.
If you stop using the logo but continue to use the heading, you will finally see that the logo is above the heading and ozone.
So, an example of what needs to be done is the following:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <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/my_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/action_bar_background" app:theme="@style/NewToolBarStyle" android:minHeight="?attr/actionBarSize" /> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/text_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="17dp" android:textSize="20sp" android:layout_toRightOf="@+id/logo_image" android:text="@string/app_name" android:textColor="@color/white" /> <ImageView android:id="@+id/logo_image" android:layout_width="45dp" android:layout_height="45dp" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:scaleType="centerInside" /> </RelativeLayout> </FrameLayout>
You create this file as my_toolbar.xml. Pay attention to the following data:
- I did not enable src of my ImageView because I am changing it dynamically. But the work is being added.
- I used relative layout to center the icon and text.
- I need to enable the home button.
Later, as described by @brightstar, you need to include at the top of your layouts with include, however .... remember to add an identifier so that you can reference all your other Views.
<include layout="@layout/toolbar_sharemup" android:id="@+id/including" />
source share