애니메이션으로 활동 시작 | Android 개발자 | Android Developers
애니메이션으로 활동 시작 | Android 개발자 | Android Developers
애니메이션으로 활동 시작 컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. 머티어리얼 디자인 앱의 활동 전환은 공통 요소 간의 모션 및 변환을 통해 서로
developer.android.com
적용하는 방법은 쉽다.
하지만 AndroidManifest에서 activity부분 또는 fragment 부분을 수정했다면 확인이 필요하다.
나 같은 경우에는 launchMode가 singleInstance인 경우 작동하지 않았다.
-> https://stackoverflow.com/questions/32650545/shared-element-transition-issue-between-two-activities
Shared Element Transition issue between two Activities
I'm having issues creating a basic shared element transition. The transition from one activity to the next seems to glitch and reproduce the first activity instead of the resulting activity. Overv...
stackoverflow.com
설정 방법
1. 이동하기 전 view, 이동한 후 view의 속성에서 transitionName 설정
<!-- A Activity -->
<View
android:id="@+id/view_bottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/background_white"
android:transitionName="bottom_trans"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/view_top" />
<!-- B Activity -->
<View
android:id="@+id/view_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background_white"
android:transitionName="bottom_trans"
app:layout_constraintTop_toBottomOf="@id/gl_center" />
2. intent 하기 전 bundle option 설정
import android.util.Pair as UtilPair
/** A Activity -> B Activity */
intent = Intent(context, BActivity::class.java)
val clTopPair = UtilPair.create<View, String>(binding.viewTop, "top_trans")
val clBottomPair = UtilPair.create<View, String>(binding.viewBottom, "bottom_trans")
val options =
ActivityOptions.makeSceneTransitionAnimation(
this@AActivity,
clTopPair,
clBottomPair,
)
startActivity(intent, options.toBundle())
끝.
'안드로이드 > Design' 카테고리의 다른 글
Figma로 앱 설계 (다크모드) (0) | 2023.03.02 |
---|---|
안드로이드 BottomNavigationView 커스텀하기 (0) | 2022.10.07 |