- res 폴더에 새로운 폴더(anim) 생성
slide_in_left.xml / slide_out_right.xml / slide_in_right.xml / slide_out_left.xml
( * X를 Y로 바꿔주면 위아래로 슬라이드가 적용된다. )
1
2
3
4
5
6
|
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="250"
android:fromXDelta="100%"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0%" />
|
cs |
1
2
3
4
5
6
|
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="250"
android:fromXDelta="-100%"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0%" />
|
cs |
1
2
3
4
5
6
|
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="250"
android:fromXDelta="0%"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="-100%" />
|
cs |
1
2
3
4
5
6
|
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="250"
android:fromXDelta="0%"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="100%" />
|
cs |
- Main Activity에서 slide 사용
overridePendingTransition( 새로 들어올 Activity, 기존 Activity)
1
2
3
4
5
|
val messageIntent = Intent(this, MessageActivity::class.java)
startActivity(messageIntent)
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right)
finish()
|
cs |
- Sub Activity 에서 Slide 사용
1
2
3
4
|
backBtn.setOnClickListener {
finish()
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_right)
}
|
cs |