gpt4 book ai didi

android - CardView动画: raise and expand on click?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:48:35 28 4
gpt4 key购买 nike

我目前正在创建我的第一个 Android 应用程序,并且想知道将 cardview 设置为升起然后扩展为更大的矩形以显示新 fragment 的方法是什么?

编辑:(无论原始卡片位于何处,新 fragment 都会填满屏幕的中心三分之一)

最佳答案

Authentic Motion

Tangible surfaces don’t just appear out of nowhere like a jump-cut in a movie; they move into place helping to focus attention, establish spatial relationships and maintain continuity. Materials respond to touch to confirm your interaction and all changes radiate outward from your touch point. All motion is meaningful and intimate, aiding the user’s comprehension.

Activity + Fragment Transitions

By declaring ‘shared elements’ that are common across two screens you can create a smooth transition between the two states.

album_grid.xml

<ImageView

android:transitionName="@string/transition_album_cover" />
album_details.xml

<ImageView

android:transitionName="@string/transition_album_cover" />

AlbumActivity.java
Intent intent = new Intent();
String transitionName = getString(R.string.transition_album_cover);

ActivityOptionsCompat options =
ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
albumCoverImageView, // The view which starts the transition
transitionName // The transitionName of the view we’re transitioning to
);
ActivityCompat.startActivity(activity, intent, options.toBundle());

Here we define the same transitionName in two screens. When starting the new Activity and this transition is animated automatically. In addition to shared elements, you can now also choreograph entering and exiting elements.

来源:Implementing Material Design

关于android - CardView动画: raise and expand on click?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27736848/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com