https://github.com/mhashim6/viewpagerdsl
Kotlin DSL for ViewPager and FragmentPagerAdapter
https://github.com/mhashim6/viewpagerdsl
adapter android dsl fragmentpageradapter fragments kotlin kotlin-android viewpager
Last synced: 6 months ago
JSON representation
Kotlin DSL for ViewPager and FragmentPagerAdapter
- Host: GitHub
- URL: https://github.com/mhashim6/viewpagerdsl
- Owner: mhashim6
- License: apache-2.0
- Created: 2018-04-18T18:42:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-27T12:46:31.000Z (over 7 years ago)
- Last Synced: 2025-03-26T13:45:43.459Z (7 months ago)
- Topics: adapter, android, dsl, fragmentpageradapter, fragments, kotlin, kotlin-android, viewpager
- Language: Kotlin
- Homepage:
- Size: 63.5 KB
- Stars: 17
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ViewPagerDSL
Kotlin DSL for ViewPager and FragmentPagerAdapter[](https://jitpack.io/#mhashim6/ViewPagerDSL)
## Usage:
```kotlin
viewPager.apply {fragmentPagerAdapter(pageCount = 3, fragmentManager = supportFragmentManager) {
pages { position ->
when (position) {
0 -> Pair(InputFragment(), "Entries")
1 -> Pair(OutputFragment(), "Result")
2 -> Pair(AboutFragment(), "About Us")
else -> throw Exception("¯\\_(ツ)_/¯")
}
}
onPageSelected { position ->
//nice moves go here.
}
clipToPadding = false
offscreenPageLimit = 2
}
```
## Dependency:
Add it in your root build.gradle at the end of repositories:```groovy
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
Add the dependency:
```groovy
dependencies {
implementation 'com.github.mhashim6:ViewPagerDSL:1.0.2'
}
```