- Add the JitPack repository to your build file
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
- Add the dependency
dependencies {
compile 'com.github.kmcgill88:McPicSlider-Android:0.1.0'
}
<activity
android:name="com.mcgilldevtech.mcpicslider.McPicSliderFullScreenActivity"
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen">
</activity>
- Add XML
<com.mcgilldevtech.mcpicslider.McViewPager
android:id="@+id/mcViewPager"
android:layout_width="match_parent"
android:layout_height="400dp" />
- Write a little code
val mcPicSlider = findViewById<McViewPager>(R.id.mcViewPager)
mcPicSlider.useFullScreen = true // Default: False. If true, you must declare McPicSliderFullScreenActivity in your manifest
mcPicSlider.adapter = McPicSliderAdapterFresco(
context = this,
onImageTapped = { position, url ->
Toast.makeText(this, "You clicked image " + (position + 1), Toast.LENGTH_SHORT).show()
},
images = listOf(
"https://cats.com/scared-kitten.jpg",
"https://cats.com/hypoallergenic-cat-breeds.jpg",
"https://cats.com/super-cool-cat.jpg"
)
)
Kevin McGill, [email protected]
McPicSlider-Android is available under the MIT license. See the LICENSE file for more info.