{"id":27309478,"url":"https://github.com/solartcc/nestedceilingeffect","last_synced_at":"2026-02-27T19:03:35.592Z","repository":{"id":40676144,"uuid":"280372953","full_name":"solartcc/NestedCeilingEffect","owner":"solartcc","description":"A nested sliding ceiling effect Component.","archived":false,"fork":false,"pushed_at":"2020-07-18T09:49:10.000Z","size":22004,"stargazers_count":35,"open_issues_count":1,"forks_count":6,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-12T05:33:56.873Z","etag":null,"topics":["ceiling","nested","recyclerview"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solartcc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-17T08:40:55.000Z","updated_at":"2025-03-20T11:46:13.000Z","dependencies_parsed_at":"2022-08-27T01:52:25.091Z","dependency_job_id":null,"html_url":"https://github.com/solartcc/NestedCeilingEffect","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/solartcc/NestedCeilingEffect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solartcc%2FNestedCeilingEffect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solartcc%2FNestedCeilingEffect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solartcc%2FNestedCeilingEffect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solartcc%2FNestedCeilingEffect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solartcc","download_url":"https://codeload.github.com/solartcc/NestedCeilingEffect/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solartcc%2FNestedCeilingEffect/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262885410,"owners_count":23379591,"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":["ceiling","nested","recyclerview"],"created_at":"2025-04-12T05:29:50.197Z","updated_at":"2026-02-27T19:03:35.554Z","avatar_url":"https://github.com/solartcc.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"NestedCeilingEffect project\n===============\n\n一个嵌套滑动吸顶交互效果的控件。\n\n[也许是最贴近京东体验的嵌套滑动吸顶效果](http://solart.cc/2020/07/17/nested_ceiling_effect/)\n\n效果展示（由于 gif 图过大，或请通过 run demo查看）：\n\n\u003cimg src=\"./preview/live.gif\" width=220\u003e\n\n提供了两种外层的嵌套滑动控件 `NestedParentRecyclerView` 以及 `NestedParentScrollView` ，首先介绍 `NestedParentScrollView` 的用法：\n\n## Usage `NestedParentScrollView` \n\n#### Step 1. 通过布局文件引入\n\n在外层布局文件中添加 NestedParentScrollView，\n\n```xml\n\u003ccc.solart.nestedceiling.widget.NestedParentScrollView\n    android:id=\"@+id/nested_parent\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n\n    \u003cLinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\u003e\n\n        \u003c!-- 头部布局 --\u003e\n        \u003cHeaderView\n            ... /\u003e\n\t\t\u003c!-- 需要吸附的布局 --\u003e\n        \u003cLinearLayout\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            android:orientation=\"vertical\"\u003e\n\n            \u003ccom.google.android.material.tabs.TabLayout\n                android:id=\"@+id/tab_layout\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"wrap_content\"/\u003e\n\n            \u003candroidx.viewpager2.widget.ViewPager2\n                android:id=\"@+id/view_pager\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\" /\u003e\n        \u003c/LinearLayout\u003e\n\n    \u003c/LinearLayout\u003e\n\n\n\u003c/cc.solart.nestedceiling.widget.NestedParentScrollView\u003e\n```\n\n在子 tab 布局文件中添加 NestedChildRecyclerView\n\n```xml\n\u003ccc.solart.nestedceiling.widget.NestedChildRecyclerView\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:id=\"@+id/recycler_view\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n\n\u003c/cc.solart.nestedceiling.widget.NestedChildRecyclerView\u003e\n```\n\n#### Step 2. 在代码中使用\n\n```kotlin\nval nestedParent: NestedParentScrollView = findViewById(R.id.nested_sv)\n...\n```\n\n#### Step 3. 添加吸附状态监听\n\n```kotlin\n// 如果需要监听吸附的状态变化\nnestedParent.addOnChildAttachStateListener(object :OnChildAttachStateListener{\n            override fun onChildDetachedFromTop() {\n                topAnchor.visibility = View.GONE\n            }\n\n            override fun onChildAttachedToTop() {\n                topAnchor.visibility = View.VISIBLE\n            }\n\n        })\n```\n\n## Usage `NestedParentRecyclerView` \n\n#### Step 1. 通过布局文件引入\n\n在外层布局文件中添加 NestedParentRecyclerView\n\n```xml\n\u003ccc.solart.nestedceiling.widget.NestedParentRecyclerView\n\tandroid:id=\"@+id/nested_rv\"\n\tandroid:layout_width=\"match_parent\"\n\tandroid:layout_height=\"match_parent\"\u003e\n\n\u003c/cc.solart.nestedceiling.widget.NestedParentRecyclerView\u003e\n```\n\n在子 tab 布局文件中添加 NestedChildRecyclerView\n\n```xml\n\u003ccc.solart.nestedceiling.widget.NestedChildRecyclerView\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:id=\"@+id/recycler_view\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n\n\u003c/cc.solart.nestedceiling.widget.NestedChildRecyclerView\u003e\n```\n\n#### Step 2. 在代码中使用\n\n```kotlin\nval recyclerView: NestedParentRecyclerView = findViewById(R.id.nested_rv)\nrecyclerView.layoutManager = LinearLayoutManager(this)\nrecyclerView.adapter = adapter\n...\n```\n\n将要吸附的控件，作为最后一个 RecyclerView 的 item 加入 adapter 中即可。\n\n#### Step 3. 添加吸附状态监听\n\n```kotlin\n// 如果需要监听吸附的状态变化\nnestedParent.addOnChildAttachStateListener(object :OnChildAttachStateListener{\n            override fun onChildDetachedFromTop() {\n                topAnchor.visibility = View.GONE\n            }\n\n            override fun onChildAttachedToTop() {\n                topAnchor.visibility = View.VISIBLE\n            }\n\n        })\n```\n\n以上用法如有疑问，请参看 demo，欢迎建议交流、Issues、Star\n\n#### 已知问题\n\n- Fling 状态传递偶有略微延迟（跟递归查找滑动子 View 有关，如果要优化可从外部传入状态，省去查找时间，为了保持灵活性暂未处理）\n\n## Thanks\n\n- [MultiType](https://github.com/drakeet/MultiType)\n- [Banner](https://github.com/youth5201314/banner)\n\nLicense\n-------\n\n    Copyright 2016 solartisan/blue\n    \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n        http://www.apache.org/licenses/LICENSE-2.0\n    \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolartcc%2Fnestedceilingeffect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolartcc%2Fnestedceilingeffect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolartcc%2Fnestedceilingeffect/lists"}