0

I am looking a create a toolbar like whatsapp profile with co-ordinator layout.enter image description here

But I am only able to show the main title on toolbar which has pinning property on action bar.

How can I add the sub title text and icon/custom view on the right , which has a similar pinning on actionbar property.

I have tried adding layout inside Toolbar tag in xml.

    <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:id="@+id/appbar"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:fitsSystemWindows="true"
  android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

  <android.support.design.widget.CollapsingToolbarLayout
    android:layout_width="match_parent"
    android:layout_height="400dp"
    android:fitsSystemWindows="true"
    app:contentScrim="?attr/colorPrimary"
    app:expandedTitleMarginEnd="@dimen/activity_horizontal_margin"
    app:expandedTitleMarginStart="@dimen/activity_horizontal_margin"
    app:layout_scrollFlags="scroll|exitUntilCollapsed">

    <ImageView
      android:id="@+id/toolbar_image"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:adjustViewBounds="true"
      android:contentDescription="@null"
      android:fitsSystemWindows="true"
      android:scaleType="centerCrop"
      android:src="@drawable/beach_huts"
      app:layout_collapseMode="parallax" />

    <android.support.v7.widget.Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="?attr/actionBarSize"
      app:layout_collapseMode="pin"
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >

     <!-- adding views ,layouts here does not work -->
    </android.support.v7.widget.Toolbar>

  </android.support.design.widget.CollapsingToolbarLayout>

  <android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:layout_gravity="bottom"
    app:layout_scrollFlags="scroll" />

</android.support.design.widget.AppBarLayout>
Gaurav
  • 667
  • 2
  • 13
  • 28

0 Answers0