{"id":13428721,"url":"https://github.com/tommybuonomo/creative-viewpager","last_synced_at":"2025-04-05T02:11:21.000Z","repository":{"id":53151114,"uuid":"132056317","full_name":"tommybuonomo/creative-viewpager","owner":"tommybuonomo","description":"Creative View Pager easy to use in Android","archived":false,"fork":false,"pushed_at":"2018-06-20T20:20:43.000Z","size":49852,"stargazers_count":738,"open_issues_count":8,"forks_count":88,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-03-29T01:13:28.041Z","etag":null,"topics":["android-library","creative","creative-coding","viewpager","viewpager-transformer","viewpagers"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/tommybuonomo.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":"2018-05-03T22:32:51.000Z","updated_at":"2025-02-19T09:12:47.000Z","dependencies_parsed_at":"2022-09-13T17:42:17.701Z","dependency_job_id":null,"html_url":"https://github.com/tommybuonomo/creative-viewpager","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommybuonomo%2Fcreative-viewpager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommybuonomo%2Fcreative-viewpager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommybuonomo%2Fcreative-viewpager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tommybuonomo%2Fcreative-viewpager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tommybuonomo","download_url":"https://codeload.github.com/tommybuonomo/creative-viewpager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276189,"owners_count":20912288,"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":["android-library","creative","creative-coding","viewpager","viewpager-transformer","viewpagers"],"created_at":"2024-07-31T01:01:03.514Z","updated_at":"2025-04-05T02:11:20.981Z","avatar_url":"https://github.com/tommybuonomo.png","language":"Kotlin","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# Creative View Pager\n\nCreative View Pager easy to use !\nThis view pager library combines a header list which is scrolling automatically in coordination with the page contents.\n\n![CreativeViewPager](/art/creative-viewpager1.gif)\n\n## Download\n```Gradle\ndependencies {\n    implementation 'com.tbuonomo:creative-viewpager:1.0.1'\n}\n```\n\n## Usage\n\n### In your XML layout\nAdd `CreativeViewPager` in your activity's layout\n```Xml\n\u003ccom.tbuonomo.creativeviewpager.CreativeViewPager\n    android:id=\"@+id/creativeViewPagerView\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    app:contentHorizontalPadding=\"32dp\"\n    app:contentMargin=\"8dp\"\n    app:imagesMargin=\"8dp\"\n    app:imagesSize=\"92dp\"\n    /\u003e\n```\nYou will see a fake preview in Android Studio of the creative view.\n\n### Custom XML Attributes\n| Attribute | Description |\n| --- | --- |\n| `contentHorizontalPadding` | The start and end padding in dp of the content pages relative to the parent layout (by default 32dp) |\n| `contentItemMargin` | Margin in dp of each content item (by default 8dp) |\n| `headerItemMargin` | Margin in dp of each header item (by default 8dp) |\n| `headerItemSize` | The size in dp of the header items (by default 92dp) |\n\n### Adapter\nCreate your own adapter extending `CreativeViewAdapter`\n```Kotlin\nclass NatureCreativePagerAdapter(val context: Context) : CreativePagerAdapter\n```\n\nBy default, you have to override the 3 methods `instantiateHeaderItem`, `instantiateContentItem` and `getCount`.\n\n```Kotlin\n    override fun instantiateHeaderItem(inflater: LayoutInflater, container: ViewGroup, position: Int): View {\n    // Inflate page layout\n    val headerRoot = inflater.inflate(R.layout.item_creative_content_nature, container, false)\n\n    // Bind the views\n    val title: TextView = headerRoot.findViewById(R.id.itemCreativeNatureTitle)\n    val image: ImageView = headerRoot.findViewById(R.id.itemCreativeNatureImage)\n\n    title.text = context.getString(R.string.item_nature_title, position)\n    image.setImageDrawable(context.getDrawable(NatureItem.values()[position].natureDrawable))\n\n    return headerRoot\n  }\n\n  override fun instantiateContentItem(inflater: LayoutInflater, container: ViewGroup, position: Int): View {\n    // Inflate the header view layout\n    val contentRoot = inflater.inflate(R.layout.item_creative_header_profile, container,\n            false)\n\n    // Bind the views\n    val imageView = contentRoot.findViewById\u003cImageView\u003e(R.id.itemCreativeImage)\n\n    imageView.setImageDrawable(ContextCompat.getDrawable(context, NatureItem.values()[position].userDrawable))\n    return contentRoot\n  }\n\n  override fun getCount(): Int {\n    return NatureItem.values().size\n  }\n```\n\nIf you want to have the cool colored background effect when you're sliding the view pager, you have to override the two methods and provide the bitmap used for specific position.\n\n```Kotlin\n  override fun isUpdatingBackgroundColor(): Boolean {\n    return true\n  }\n\n  override fun requestBitmapAtPosition(position: Int): Bitmap? {\n    // Return the bitmap used for the position\n    return BitmapFactory.decodeResource(context.resources,\n            NatureItem.values()[position].natureDrawable)\n  }\n```\n\n### In your Activity / Fragment\nFinally, set your adapter to the `CreativeViewPager` in your activity or fragment.\n```Kotlin\ncreativeViewPagerView.setCreativeViewPagerAdapter(NatureCreativePagerAdapter(activity))\n```\n\nDon't forget to star the project if you like it! \n![star](https://user-images.githubusercontent.com/15737675/39397370-85f5b294-4afe-11e8-9c02-0dfdf014136a.png)\n == ![heart](https://user-images.githubusercontent.com/15737675/39397367-6e312c2e-4afe-11e8-9fbf-32001b0165a1.png)\n\n## Changelog\n### 1.0.1\n- Rename class `CreativeViewPagerView` to `CreativeViewPager`\n- Rename class `CreativeViewAdapter` to `CreativePagerAdapter`\n- Rename attribute `imagesMargin` to `headerItemMargin`\n- Rename attribute `imagesSize` to `headerItemSize`\n- Rename attribute `contentMargin` to `contentItemMargin`\n- Add the `setCurrentItem(position: Int)` to `CreativeViewPager`\n\n\n[Icons](https://www.flaticon.com/packs/profession-avatars) designed by [Freepics](https://www.flaticon.com/authors/freepik) from [Flaticon](https://www.flaticon.com/)\n\n## License\n    Copyright 2018 Tommy Buonomo\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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftommybuonomo%2Fcreative-viewpager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftommybuonomo%2Fcreative-viewpager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftommybuonomo%2Fcreative-viewpager/lists"}