-
Notifications
You must be signed in to change notification settings - Fork 5
5.1. 스플래시
JiHwan edited this page Jan 15, 2021
·
2 revisions
- lottie 영상 추가
- 화면 전환을 위해 viewpager를 사용하였고 TabLayout custom
private fun initLottie() {
binding.splash.addAnimatorListener(object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator?) {
}
override fun onAnimationEnd(animation: Animator?) {
if (FourMostPreference.getFirstVisit()) {
startActivity(Intent(this@SplashActivity, ServiceExplainActivity::class.java))
} else {
startActivity(Intent(this@SplashActivity, SignInActivity::class.java))
}
finish()
}
override fun onAnimationCancel(animation: Animator?) {
}
override fun onAnimationRepeat(animation: Animator?) {
}
})
}
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.view.splash.SplashActivity">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/splash"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_rawRes="@raw/splashview"
app:lottie_autoPlay="true"
app:lottie_loop="false" />
</androidx.constraintlayout.widget.ConstraintLayout>
private fun viewPagerChange() {
binding.vpServiceExplain.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrolled(
position: Int,
positionOffset: Float,
positionOffsetPixels: Int
) {
btnOnOff()
}
override fun onPageSelected(position: Int) {
btnOnOff()
}
override fun onPageScrollStateChanged(state: Int) {
}
})
}
<com.google.android.material.tabs.TabLayout
android:id="@+id/tl_splash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:tabBackground="@drawable/selector_tab_indicator"
app:tabGravity="center"
app:tabIndicator="@null"
app:tabPaddingEnd="9dp"
app:tabPaddingStart="9dp"
android:layout_marginTop="72dp">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp_service_explain"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/btn_explain_finish"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tl_splash" />