Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: Create layout which collapse on scrolling

I need a layout(view1) which on scrolling listview gets collapsed, so that listview have full screen height? Like this.

like image 569
Ankur Jain Avatar asked Nov 17 '15 13:11

Ankur Jain


2 Answers

Use collapsing Toolbar layout for your requirment.

<android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsingToolbarLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:contentScrim="?attr/colorPrimaryDark"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="centerCrop"
            android:src="@drawable/abcd"
            app:layout_collapseMode="parallax"
            app:layout_collapseParallaxMultiplier="0.7" />

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

        </android.support.v7.widget.Toolbar>

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

refer this link for help Design support library

like image 113
curiousMind Avatar answered Nov 01 '22 06:11

curiousMind


You can do that with android material design and make the AppBar collapse on scroll.Also add this attribute to your listView

app:layout_behaviour="@string/appbar_scrolling_view_behavior"

Use this link for more info here

like image 1
Collins Abitekaniza Avatar answered Nov 01 '22 04:11

Collins Abitekaniza