Skip to content

AndroidPoet/Material-Intro

Repository files navigation

Material Intro

Sophisticated and cool intro with Material Motion Animations.

Google

License Profile



Who's using Material Intro?

👉 Check out who's using Material Intro

Include in your project

Maven Central

Gradle

Add the dependency below to your module's build.gradle file:

dependencies {
    implementation("io.github.androidpoet:materialintro:1.0.8")
}

SetUp for Views

<com.androidpoet.materialintro.MaterialIntroView
android:id="@+id/materialintroView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.androidpoet.materialintro.MaterialIntroView>
//add views into list
  list.add(R.layout.layout_one)
  list.add(R.layout.layout_two)
  list.add(R.layout.layout_three)


   with(binding.materialintroView) {
      setViewsList(list)
      nextAnimation = IntroAnimation.Fade
      previousAnimation = IntroAnimation.Fade
      nextDuration = 500
      previousDuration = 500
    }


//  go next view with animation
binding.nextButton.setOnClickListener {
    binding.materialIntroFragment.next()
}

//  go previous view with animation
binding.backButton.setOnClickListener {
    binding.materialIntroFragment.previous()
}

SetUp for Fragments

<com.androidpoet.materialintro.MaterialIntroFragment
android:id="@+id/materialintroView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.androidpoet.materialintro.MaterialIntroFragment>
//add fragments into list
list.add(FragmentOne())
list.add(FragmentTwo())
list.add(FragmentThree())
	
  binding.materialIntroFragment.apply {
      setFragmentsList(list)
      enterAnimation = IntroAnimation.SharedAxisXForward
     
      enterDuration = 500
   
    }


//  go next view with animation
binding.nextButton.setOnClickListener {
    binding.materialintroView.next()
}

//  go previous view with animation
binding.backButton.setOnClickListener {
    binding.materialintroView.previous()
}

Supported Animations

IntroAnimation.None
IntroAnimation.FadeThrough
IntroAnimation.Fade
IntroAnimation.SharedAxisXForward
IntroAnimation.SharedAxisYForward
IntroAnimation.SharedAxisZForward
IntroAnimation.SharedAxisXBackward
IntroAnimation.SharedAxisYBackward
IntroAnimation.SharedAxisZBackward
IntroAnimation.ElevationScaleGrow
IntroAnimation.ElevationScale

Create using Builder

We can create the MaterialIntro using MaterialIntro.Builder.

val meta = MaterialIntroFragment.Builder(this)
 .setFragmentsList(list)
.setEnterAnimation(IntroAnimation.Fade)
.setEnterDuration(300)
.setEnterOverlap(true)
.build()

meta.next()
meta.previous()

This is how to create an instance of the MaterialIntro using kotlin dsl.

val meta = materialIntroFragment(this) {
setFragmentsList(list)
setEnterAnimation(IntroAnimation.Fade)
setEnterDuration(300)
setEnterOverlap(true)
build()
}
meta.next()
meta.previous()

MaterialFade


Fade


SharedAxis


Card icons created by Freepik - Flaticon

Find this library useful? ❤️

Support it by joining stargazers for this repository. ⭐

Buy Me A Coffee

License

Copyright 2022 AndroidPoet (Ranbir Singh)

Licensed 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

http://www.apache.org/licenses/LICENSE-2.0

Unless 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.