Android/Tips
Google Map에 사용자지정 액티비티 전환 적용 방법
JamesY
2018. 1. 8. 17:54
1. 기본 환경 세팅
- 두 액티비티 모두 Google Map 적용
- 사용자지정 액태비티 전환을 위한 코드 삽입
https://developer.android.com/training/material/animations.html?hl=ko#Transitions
2. Google Map에 적용
두 액티비티의 소스 코드 중 초기 Google Map Fragment를 가져오는 부분에 추가
val mapFragment = supportFragmentManager
.findFragmentById(R.id.map) as SupportMapFragment
mapFragment.view!!.transitionName = resources.getString(R.string.shared_element_map)
Fragment의 View를 가져와 TransitionName을 넣는다.
넣은 후 액티비티 전환을 위한 Intent의 Options을 정의할 때 다음과 같이 추가한다.
var options = ActivityOptionsCompat.makeSceneTransitionAnimation(this,
Pair<View, String>(map.view, ViewCompat.getTransitionName(map.view)))