Custom layout in Toolbar with TabLayout below

筅森魡賤 提交于 2019-12-05 11:50:47

AppBarLayout extends LinearLayout, so you can add any number of views to your AppBarLayout: there's no reason to add the views specifically to your Toolbar.

You'll want to make sure you use the same layout_scrollFlags as your Toolbar if you want them to scroll the same.

Toolbar is just a ViewGroup, you can customize is as much as you want.

Try this :

<android.support.v7.widget.Toolbar
 style="@style/ToolBarStyle"
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="?attr/colorPrimary"
 android:minHeight="@dimen/abc_action_bar_default_height_material">

<ImageView
    android:layout_width="wrap_content"
    android:contentDescription="@string/logo"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:src="@drawable/ic_launcher"/>

This should bring your imageView in center of toolbar.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!