Umashankar B
Umashankar B

Reputation: 425

CollapsingToolbarLayout with image on toolbar android

I am using CollapsingToolbarLayout,I want to display profile pic on toolbar along with title, when collapsingToolbarLayout lifted up.Please provide related code or library.

Upvotes: 2

Views: 7347

Answers (1)

Avinash kumawat
Avinash kumawat

Reputation: 75

Use like this :

 <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:fitsSystemWindows="false"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleTextAppearance="@style/TransparentText"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">


            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clickable="true"
                android:foreground="?attr/selectableItemBackground"
                android:orientation="vertical"

                android:paddingTop="?actionBarSize"
                app:layout_collapseMode="parallax">


                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:src="@drawable/test_img"
                    android:id="@+id/profile_image">

                </ImageView>


            </FrameLayout>


            <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/AppTheme.PopupOverlay" />

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


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

Use it in your coordinateLayout. and position your image as you like.

Upvotes: 1

Related Questions