{"id":13641779,"url":"https://github.com/BCsl/GalleryLayoutManager","last_synced_at":"2025-04-20T11:32:13.274Z","repository":{"id":42201178,"uuid":"76538069","full_name":"BCsl/GalleryLayoutManager","owner":"BCsl","description":"New way to implements ViewPager/Gallery in Android with RecycleView","archived":false,"fork":false,"pushed_at":"2022-08-23T03:25:22.000Z","size":3052,"stargazers_count":955,"open_issues_count":22,"forks_count":141,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-08-03T01:24:45.001Z","etag":null,"topics":["gallery","layoutmanager","recyclerview","viewpager"],"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/BCsl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-15T08:08:33.000Z","updated_at":"2024-07-14T23:18:22.000Z","dependencies_parsed_at":"2022-07-10T20:34:47.040Z","dependency_job_id":null,"html_url":"https://github.com/BCsl/GalleryLayoutManager","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BCsl%2FGalleryLayoutManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BCsl%2FGalleryLayoutManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BCsl%2FGalleryLayoutManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BCsl%2FGalleryLayoutManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BCsl","download_url":"https://codeload.github.com/BCsl/GalleryLayoutManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223827696,"owners_count":17209830,"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":["gallery","layoutmanager","recyclerview","viewpager"],"created_at":"2024-08-02T01:01:24.342Z","updated_at":"2025-04-20T11:32:13.266Z","avatar_url":"https://github.com/BCsl.png","language":"Java","readme":"# GalleryLayoutManager\n\n[中文](./README_CN.md)\n\nA custom LayoutManager to build a Gallery or a ViewPager like RecyclerView that shows items in a center-locked and support both HORIZONTAL and VERTICAL scroll.And View Recycle Machine is also supported.\n\n## Screenshots\n\n![ViewPager](./screenshots/ViewPager.gif)\n\n![Demo](./screenshots/demo.gif)\n\n## Usage\n\n### 1、Build\n\n#### Gradle\n\n```groovy\nimplementation 'github.hellocsl:GalleryLayoutManager:{latest-release-version}'\n```\n\n### 2、In your code\n\n#### Basis Usage\n\nUse `GalleryLayoutManager#attach(RecycleView recycleView)` to setup `GalleryLayoutManager` for your `RecycleView` instead of `RecycleView#setLayoutManager(LayoutManager manager)`\n\n```java\nGalleryLayoutManager layoutManager = new GalleryLayoutManager(GalleryLayoutManager.HORIZONTAL);\n//layoutManager.attach(mPagerRecycleView);  // default selected position is 0\nlayoutManager.attach(mPagerRecycleView, 30);\n\n//...\n//setup adapter for your RecycleView\nmPagerRecycleView.setAdapter(imageAdapter);\n```\n\n#### Listen to selection change\n\n```java\nlayoutManager.setCallbackInFling(true);//should receive callback when flinging, default is false\nlayoutManager.setOnItemSelectedListener(new GalleryLayoutManager.OnItemSelectedListener() {\n    @Override\n    public void onItemSelected(RecyclerView recyclerView, View item, int position) {\n        //.....\n    }\n});\n```\n\n#### Apply ItemTransformer just like ViewPager\n\nImplements your `ItemTransformer`\n\n```java\npublic class ScaleTransformer implements GalleryLayoutManager.ItemTransformer {\n\n    @Override\n    public void transformItem(GalleryLayoutManager layoutManager, View item, float fraction) {\n        item.setPivotX(item.getWidth() / 2.F);\n        item.setPivotY(item.getHeight() / 2.F);\n        float scale = 1 - 0.3F * Math.abs(fraction);\n        item.setScaleX(scale);\n        item.setScaleY(scale);\n    }\n}\n```\n\n```java\n// Apply ItemTransformer just like ViewPager\nlayoutManager.setItemTransformer(new ScaleTransformer());\n```\n\n## License\n\n```\nCopyright [2017] [Hello Csl]\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\n\u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n```\n","funding_links":[],"categories":["ViewPager"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBCsl%2FGalleryLayoutManager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBCsl%2FGalleryLayoutManager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBCsl%2FGalleryLayoutManager/lists"}