{"id":13396160,"url":"https://github.com/timehop/sticky-headers-recyclerview","last_synced_at":"2025-12-30T07:57:44.907Z","repository":{"id":21425653,"uuid":"24743779","full_name":"timehop/sticky-headers-recyclerview","owner":"timehop","description":"[UNMAINTAINED] Sticky Headers decorator for Android's RecyclerView","archived":true,"fork":false,"pushed_at":"2018-10-24T21:23:54.000Z","size":337,"stargazers_count":3742,"open_issues_count":83,"forks_count":753,"subscribers_count":115,"default_branch":"master","last_synced_at":"2025-01-04T19:05:34.297Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timehop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-03T01:57:46.000Z","updated_at":"2024-12-18T04:20:09.000Z","dependencies_parsed_at":"2022-08-07T10:00:29.217Z","dependency_job_id":null,"html_url":"https://github.com/timehop/sticky-headers-recyclerview","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timehop%2Fsticky-headers-recyclerview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timehop%2Fsticky-headers-recyclerview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timehop%2Fsticky-headers-recyclerview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timehop%2Fsticky-headers-recyclerview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timehop","download_url":"https://codeload.github.com/timehop/sticky-headers-recyclerview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234556164,"owners_count":18851916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T18:00:41.523Z","updated_at":"2025-09-28T20:30:20.704Z","avatar_url":"https://github.com/timehop.png","language":"Java","funding_links":[],"categories":["Index `(light-weight pages)`","Index","Java","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"This project is no longer being maintained\n==========================================\n\nsticky-headers-recyclerview\n===========================\n\nThis decorator allows you to easily create section headers for RecyclerViews using a\nLinearLayoutManager in either vertical or horizontal orientation.\n\nCredit to [Emil Sjölander](https://github.com/emilsjolander) for creating StickyListHeaders,\na library that many of us relied on for sticky headers in our listviews.\n\nHere is a quick video of it in action (click to see the full video):\n\n[![animated gif demo](http://i.imgur.com/I0ztoPw.gif)](https://www.youtube.com/watch?v=zluBwbf3aew)\n\n[![animated gif demo](http://i.imgur.com/b5pJjtL.gif)](https://www.youtube.com/watch?v=zluBwbf3aew)\n\nDownload\n--------\n\nCurrent version: [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.timehop.stickyheadersrecyclerview/library/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.timehop.stickyheadersrecyclerview/library)\n\n    compile 'com.timehop.stickyheadersrecyclerview:library:[latest.version.number]@aar'\n\n\nUsage\n-----\n\nThere are three main classes, `StickyRecyclerHeadersAdapter`, `StickyRecyclerHeadersDecoration`,\nand `StickyRecyclerHeadersTouchListener`.\n\n`StickyRecyclerHeadersAdapter` has a very similar interface to the `RecyclerView.Adapter`, and it\nis recommended that you make your `RecyclerView.Adapter` implement `StickyRecyclerHeadersAdapter`.\n\nThere interface looks like this:\n\n```java\npublic interface StickyRecyclerHeadersAdapter\u003cVH extends RecyclerView.ViewHolder\u003e {\n  public long getHeaderId(int position);\n\n  public VH onCreateHeaderViewHolder(ViewGroup parent);\n\n  public void onBindHeaderViewHolder(VH holder, int position);\n\n  public int getItemCount();\n}\n```\n\nThe second class, `StickyRecyclerHeadersDecoration`, is where most of the magic happens, and does\nnot require any configuration on your end.  Here's an example from `onCreate()` in an activity:\n\n```java\nmRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);\nmAdapter = new MyStickyRecyclerHeadersAdapter();\nmRecyclerView.setAdapter(mAdapter);\nmRecyclerView.setLayoutManager(new LinearLayoutManager(context));\nmRecyclerView.addItemDecoration(new StickyRecyclerHeadersDecoration(mAdapter));\n```\n\n`StickyRecyclerHeadersTouchListener` allows you to listen for clicks on header views.\nSimply create an instance of `StickyRecyclerHeadersTouchListener`, set the `OnHeaderClickListener`,\nand add the `StickyRecyclerHeadersTouchListener` as a touch listener to your `RecyclerView`.\n\n```java\nStickyRecyclerHeadersTouchListener touchListener =\n    new StickyRecyclerHeadersTouchListener(recyclerView, headersDecor);\ntouchListener.setOnHeaderClickListener(\n    new StickyRecyclerHeadersTouchListener.OnHeaderClickListener() {\n      @Override\n      public void onHeaderClick(View header, int position, long headerId) {\n        Toast.makeText(MainActivity.this, \"Header position: \" + position + \", id: \" + headerId,\n            Toast.LENGTH_SHORT).show();\n      }\n    });\nmRecyclerView.addOnItemTouchListener(touchListener);\n```\n\nThe StickyHeaders aren't aware of your adapter so if you must notify them when your data set changes.\n\n```java\n    mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {\n      @Override public void onChanged() {\n        headersDecor.invalidateHeaders();\n      }\n    });\n```\n\nIf the Recyclerview's layout manager implements getExtraLayoutSpace (to preload more content then is\nvisible for performance reasons), you must implement ItemVisibilityAdapter and pass an instance as a\nsecond argument to StickyRecyclerHeadersDecoration's constructor.\n```java\n    @Override\n    public boolean isPositionVisible(final int position) {\n        return layoutManager.findFirstVisibleItemPosition() \u003c= position\n            \u0026\u0026 layoutManager.findLastVisibleItemPosition() \u003e= position;\n    }\n```\n\n\nItem animators don't play nicely with RecyclerView decorations, so your mileage with that may vary.\n\nCompatibility\n-------------\n\nAPI 11+\n\nKnown Issues\n------------\n\n* The header views aren't recycled at this time.  Contributions are most welcome.\n\n* I haven't tested this with ItemAnimators yet.\n\n* The header views are drawn to a canvas, and are not actually a part of the view hierarchy. As such, they can't have touch states, and you may run into issues if you try to load images into them asynchronously.\n\nVersion History\n---------------\n0.4.3 (12/24/2015) - Change minSDK to 11, fix issue with header bounds caching\n\n0.4.2 (8/21/2015) - Add support for reverse `ReverseLayout` in `LinearLayoutManager` by [AntonPukhonin](https://github.com/AntonPukhonin)\n\n0.4.1 (6/24/2015) - Fix \"dancing headers\" by DarkJaguar91\n\n0.4.0 (4/16/2015) - Code reorganization by danoz73, fixes for different sized headers, performance improvements\n\n0.3.6 (1/30/2015) - Prevent header clicks from passing on the touch event\n\n0.3.5 (12/12/2014) - Add StickyRecyclerHeadersDecoration.invalidateHeaders() method\n\n0.3.4 (12/3/2014) - Fix issues with rendering of header views with header ID = 0\n\n0.3.3 (11/13/2014) - Fixes for padding, support views without headers\n\n0.3.2 (11/1/2014) - Bug fixes for list items with margins and deleting items\n\n0.2 (10/3/2014) - Add StickyRecyclerHeadersTouchListener\n\n0.1 (10/2/2014) - Initial Release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimehop%2Fsticky-headers-recyclerview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimehop%2Fsticky-headers-recyclerview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimehop%2Fsticky-headers-recyclerview/lists"}