This is a very simple library for Android that allows you to stick an header to a scrollable view and easily apply animation to it

Overview

StikkyHeader

This is a very simple library for Android that allows you to stick an header to a ListView and easily apply animation to it

Usage

To use the StikkyHeader library, you just need 3 lines:

  StikkyHeaderBuilder.stickTo(mListView)
    .setHeader(R.id.header, containerLayout)
    .minHeightHeader(250)
    .build();

that's all, folks!

Header Animator

Using the StikkyHeader you can create easly some nice animations extending the HeaderStikkyAnimator and using the utility AnimatorBuilder. The animations available are Translation, Scale and Fade and can be combined to build an animation during the translation of the StikkyHeader.

Example:

public class IconAnimator extends HeaderStikkyAnimator {

    @Override
    public AnimatorBuilder getAnimatorBuilder() {

        View viewToAnimate = getHeader().findViewById(R.id.icon);
        Point point = new Point(50,100) // translate to the point with coordinate (50,100);
        float scaleX = 0.5f //scale to the 50%
        float scaleY = 0.5f //scale to the 50%
        float fade = 0.2f // 20% fade

        AnimatorBuilder animatorBuilder = AnimatorBuilder.create()
            .applyScale(viewToAnimate, scaleX, scaleY)
            .applyTranslation(viewToAnimate, point)
            .applyFade(viewToAnimate, fade);

        return animatorBuilder;
    }
}

and then set the animator to the StikkyHeader:

  StikkyHeaderBuilder.stickTo(mListView)
    .setHeader(R.id.header, containerLayout)
    .minHeightHeader(250)
    .animator(new IconAnimator())
    .build();

ViewGroups supported

The StikkyHeader supports:

  • ListView
  • RecyclerView
  • ScrollView

How to integrate

Grab via Gradle:

repositories {
  maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
  compile 'com.github.carlonzo.stikkyheader:core:0.0.3-SNAPSHOT'
}

or via Maven:

<dependency>
  <groupId>com.github.carlonzo.stikkyheader</groupId>
  <artifactId>core</artifactId>
  <version>0.0.3-SNAPSHOT</version>
</dependency>

Video

Example 1 Example 2

Demo

here the [link][1] to the emulator to try few examples. [1]: https://appetize.io/embed/urptay0fdprc9dp3xzk6e41g70?screenOnly=false&scale=75

Comments
  • Doubling image on header

    Doubling image on header

    My header is doubling the size. But one is my image header and other is a blank image. How can I solve that? screenshot_2015-03-08-18-01-08 screenshot_2015-03-08-18-01-00

    code XML:

       <FrameLayout
            android:id="@+id/header"
            android:layout_width="match_parent"
            android:layout_height="180dp"
            >
    
            <ImageView
                android:id="@+id/header_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@drawable/alimentacao" />
        </FrameLayout>
    

    code Android:

        StikkyHeaderBuilder.stickTo(list)
                    .setHeader(R.id.header, parent)
                    .minHeightHeaderRes(R.dimen.min_height_header)
                    .animator(new ParallaxStikkyAnimator())
                    .build();
    
    opened by GHEEV 12
  • visual bug after items on adapter change

    visual bug after items on adapter change

    Hi, I've correctly added the header to a recycler view and everything works fine - also with animation. But, after I go to another activity, make an action that modifies the number of items on the recycler adapter (add one item at a specific position) and go back, the content is reloaded, showing the new item, but it appears a blank area at top.

    Is there something I have to do? I've tried to scroll to the top (even if it's not what I want), but it's still broken.

    onResume I just reload the content, than set the new content on the adapter and call notifyDataSetChanged().

    Any help will be appreciated.

    opened by rehacktive 6
  • Access ItemDecoration

    Access ItemDecoration

    I would like to remove item decoration created by StikkyHeader so I need to access it by reference.

    EDIT: I created a pull request for that https://github.com/carlonzo/StikkyHeader/pull/54

    opened by pawegio 3
  • Gradle error

    Gradle error

    Does anyone know how to fix the following error: Error:Module version com.github.carlonzo.stikkyheader:core:0.0.2-SNAPSHOT depends on libraries but is not a library itself

    Thanks in advance, Dorin

    opened by dorinsimina 3
  • problems after switching to another activity

    problems after switching to another activity

    Hi, I'm using your library in this way: -a main activity with viewpager; -each fragment contains an header and a recyclerview, animated through your library;

    It works perfectly unless I go from a fragment to another activity, when I go back all the scroll is messed up, the header is gone somewhere and there's a lot of "empty" space.

    I can provide more details or code if you need, but basically I only do:

        StikkyHeaderBuilder.stickTo(mRecyclerView)
                .setHeader(R.id.header, (ViewGroup) getView())
                .animator(new ParallaxStikkyAnimator())
                .build();
    

    and the animator is:

    private class ParallaxStikkyAnimator extends HeaderStikkyAnimator {
        @Override
        public AnimatorBuilder getAnimatorBuilder() {
            View mHeader_image = getHeader().findViewById(R.id.header_image);
            return AnimatorBuilder.create().applyVerticalParallax(mHeader_image);
        }
    }
    

    Is there some specific command to "restore" the recyclerview to a "good" status?

    bug 
    opened by rehacktive 3
  • Added header and item decoration accessors

    Added header and item decoration accessors

    I added accessors in case to remove & add again header on action expand & hide:

     MenuItemCompat.setOnActionExpandListener(searchMenuItem, object : MenuItemCompat.OnActionExpandListener {
                override fun onMenuItemActionExpand(item: MenuItem): Boolean {
                    stickyHeader.getHeader().setVisibility(View.GONE)
                    recyclerView.removeItemDecoration(stickyHeader.getItemDecoration())
                    return true
                }
    
                override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
                    stickyHeader.getHeader().setVisibility(View.VISIBLE)
                    recyclerView.addItemDecoration(stickyHeader.getItemDecoration())
                    return true
                }
    
            }) 
    
    opened by pawegio 2
  • How to use allowTouchBehindHeader?

    How to use allowTouchBehindHeader?

    Hi I am using this library for one of my use.

    I tried to modify your parallax sample code. I dont want the parallax effect on the image so i put that into back. I am able to achivie what i want in UI perspective. Thanks for that. But I want to add few buttons on the header and which should be clickable. Could you please let me know how to achieve this?

    Following is the xml.

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/layout_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
    
        <RelativeLayout
            android:id="@+id/bg"
            android:layout_width="match_parent"
            android:layout_height="@dimen/max_height_header">
    
            <ImageView
                android:id="@+id/header_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitXY"
                android:src="@drawable/image1" />
    
    
    
            <Button
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:text="test"
                android:id="@+id/button"
                android:background="#ffffff" />
    
        </RelativeLayout>
    
    
            <RelativeLayout
                android:id="@+id/header"
                android:clickable="true"
    
                android:layout_width="match_parent"
                android:layout_height="@dimen/max_height_header">
    
    
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="220dp"
                    android:id="@+id/textview"
                    android:text="Hello World!"
                    android:textColor="@android:color/white"
                    android:textSize="30sp" />
    
            </RelativeLayout>
    
    
    
    
        <ListView
            android:id="@+id/listview"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    
    
    
    </FrameLayout>
    
    

    Below is the code in java file.

     StikkyHeaderBuilder.stickTo(mListView)
                    .setHeader(R.id.header, (ViewGroup) getView())
                    .minHeightHeaderDim(R.dimen.max_height_header)
                    .allowTouchBehindHeader(true)
    
                    //.animator(new ParallaxStikkyAnimator())
                    .build();
    
            button.setOnTouchListener(this);
    
     @Override
        public void onClick(View v) {
            if (v.getId() == R.id.button)
                Log.e("" , "Button clicked");
        }
    
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Log.e("" , "view touched");
            return false;
        }
    
    opened by arams 2
  • RecyclerView scrollToPosition makes header go to wrong place

    RecyclerView scrollToPosition makes header go to wrong place

    Hi there, congrats for the library, it's really easy to use and works great. I'm having a small issue: whenever I do a scrollToPosition on my recyclerview the sticky header don't refresh itself. In other words if I'm at the beginning of the recyclerview and execute a scrollToPosition to the last position of the recyclerview the whole header remains in screen, event the part that is not supposed to be sticky. I can attach some images if that is not clear enough. Can someone help me? Thanks in advance.

    opened by mazoni 2
  • Notify when animation completes

    Notify when animation completes

    Hello, Thanx for your fabulous library.

    I am using it in one of my projects. Is there any way to get notified when header animation get completed.

    I mean we pass minimum height to header and scrolling gets stopped on reaching that height so is there any kinda method is there through which we could get that animation completed because I want that.

    opened by virenpurohit 1
  • Fade doesnt work

    Fade doesnt work

    animateOnScroll (AnimatorBuilder.java)

    case FADE: animatorBundle.mView.setAlpha(boundedRatioTranslationY);

    should get the final value from animatorBundle.mValues[0] and calculated the one to apply

    bug 
    opened by carlonzo 1
  • Comments for applyTranslation methods

    Comments for applyTranslation methods

    It took me some effort to figure out the meaning of translateX and translateY parameters. It wasn't clear relative to what are these parameters. Are they relative to headers top left or to the view's top let. Also I would've changed parameter names to something like finalTranslationX.

    opened by rongi 0
  • How can I integrate it with Xamarin Android code

    How can I integrate it with Xamarin Android code

    Is there a nuget package for this library so that it can be consumed by Xamarin.Android code. Currently it looks like it can be consumed by only java code.

    opened by dpjha84 0
  • How to release memory

    How to release memory

    I ran your example and found that, when I click on tab "Simple stickky header" then I press back to home screen, the memory usage increase (Seen on Android Studio IDE -> Monitor -> Memory Allocated). Then -> click the same tab -> back to home .... memory increase continuously. How to release this memory? Thank you very much!

    opened by ancuop 1
  • bug when add fragment to backstack

    bug when add fragment to backstack

    i have fragment it has a header and recyclerview if i did scroll down and clicked on item the application change the fragment but when click back and return to first fragment it shows the header full size but the recyclerview scrolled to the last position before change the fragment. and when i scroll it weird behaviors happened

    opened by mahmoudgalal2015 2
  • Force header height to min

    Force header height to min

    Hi,

    My layout is as follow :

    LAYOUT
    |_ HEADER
    |_ PAGER
       |_ MapView
       |_ RecyclerView
    |_ Floating action button
    

    When pushing the FAB, I want to animate the header to min height (if necessary) and show the map view. When pushing the FAB again, I would like to show the recycler view again (and leave the header minimized)

    Any way to do that?

    opened by vpratfr 0
  • Maven central

    Maven central

    Hello,

    Can you add a Release version in the maven central, please ? It's a little bit difficult for some project to include your project in snapshot version.

    Thanks. Regards.

    opened by Richou 0
Releases(0.0.3)
Owner
Carlo Marinangeli
Android Developer
Carlo Marinangeli
An android library for section headers that stick to the top

StickyListHeaders StickyListHeaders is an Android library that makes it easy to integrate section headers in your ListView. These section headers stic

Emil Sjölander 5.5k Jan 5, 2023
Android library to observe scroll events on scrollable views.

Android-ObservableScrollView Android library to observe scroll events on scrollable views. It's easy to interact with the Toolbar introduced in Androi

Soichiro Kashima 9.6k Dec 30, 2022
Android library that allows you to bind a LinearLayout with a ListAdapter.

LinearListView Android library that allows you to bind a LinearLayout with a ListAdapter. Download Gradle: dependencies { compile 'com.github.franki

Francesco Sardo 571 Dec 22, 2022
Horizontal list view for Android which allows variable items widths

Deprecated This widget is now deprecated and it won't be updated anymore. Use RecyclerView instead Horizontal Variable ListView Horizontal ListView fo

Alessandro Crugnola 862 Nov 15, 2022
An open source Android library that provides a floating group view at the top of the ExpandableListView

FloatingGroupExpandableListView FloatingGroupExpandableListView is a huge name an open source Android library that provides a floating group view (aka

Diego Lima 376 Nov 28, 2022
StackExpandableView - A custom view that resembles the iOS notification group behavior

StackExpandableView - A custom view that resembles the iOS notification group behavior

Fabio Sassu 155 Dec 15, 2022
Expandable Recyclerview makes it easy to integrate nested recycler view...🔨 📝

SSExpandableRecyclerView Expandable Recyclerview make it easy to integrate nested recyclerview Features Simple and easy to use ( no complex adapter re

Simform Solutions 52 Nov 1, 2022
Simple ListView based Android AccordionView

Android Accordion View Example git pull import to eclipse properties->android uncheck is library run as android application See main.xml. Screenshot L

Maciej Lopacinski 164 Nov 28, 2022
Android library to display a ListView whose cells are not rigid but flabby and react to ListView scroll.

FlabbyListView This library is not maintained anymore and there will be no further releases Android library to display a ListView which cells are not

JPARDOGO 762 Nov 23, 2022
Android library to achieve in an easy way, the behaviour of the home page in the Expedia app, with a pair of auto-scroll circular parallax ListViews.

ListBuddies This library is not maintained anymore and there will be no further releases Android library of a pair of auto-scroll circular parallax Li

JPARDOGO 970 Dec 29, 2022
Android widget with pull to refresh for all the views,and support loadMore for ListView , RecyclerView, GridView and SwipeRefreshLayout.

CommonPullToRefresh Android widget with pull to refresh for all the views,and support loadMore for ListView,RecyclerView,GridView and SwipeRefreshLayo

null 1.1k Nov 10, 2022
An Android custom ListView and ScrollView with pull to zoom-in.

PullZoomView An Android custom ListView and ScrollView with pull to zoom-in. Features Set ZoomView enable Add HeaderView Custom ZoomView Parallax or N

Frank-Zhu 2.3k Dec 26, 2022
Parallax ScrollView and ListView for Android

Parallax Scrolls Parallax ListView and ScrollView for Android This project includes ScrollView with one or more parallaxed views ListView with paralla

Nir Hartmann 851 Dec 3, 2022
android custom listview,with interaction pattern load more and pull to refresh to load data dinamically

The first thing that i have to say is render thanks to johannilsson because all the part of pull to refresh listview is based in the code of his repos

Fabian Leon 447 Nov 15, 2022
Bringing extended scrolling features to Android's native ListView and ExpandableListView.

About QuickScroll QuickScroll is a library aimed at creating similar scrolling experiences to the native Contacts app's People view. It has the same s

Andras Kindler 461 Nov 11, 2022
An easy to use Drag & Drop List for Android. Direct replacement of the android ListView.

DragNDropListView DragNDropListView is a direct replacement for the stock Android ListView. If you know how to use ListView, you already know how to u

null 187 Dec 22, 2022
Easy to use ListView with pinned sections for Android.

Easy to use ListView with pinned sections for Android 2.1 and higher. Pinned section is a header view which sticks to the top of the list until at lea

Sergej Shafarenka 2.6k Dec 21, 2022
This project aims to provide a reusable pull to refresh widget for Android.

Pull To Refresh for Android Note This library is deprecated, a swipe refresh layout is available in the v4 support library. This project aims to provi

Johan Berg 2.5k Jan 2, 2023
Lazy load of images in Android

LazyList A simple library to display images in Android ListView. Images are being downloaded asynchronously in the background. Images are being cached

Fedor Vlasov 1.2k Nov 15, 2022