本文介绍了如何扩展CardViews以显示更多细节,例如Google Keep卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一些CardView,我希望它们的功能类似于Google Keep中的卡片.例如,当我单击包含文本的卡片时,它会随着动画扩展到另一个视图中.

I have some CardViews in my app and I want them to function like the cards in Google Keep. For example, when I click on a card that has text, it expands (with the animation) into another view.

如果不确定我的意思,请在Google Keep Android应用上创建记事,然后点击创建记事时显示的即时贴.这正是我想要在我的应用程序中发生的事情.

If you're not sure what I mean, create a note on the Google Keep Android app, tap on the card that appears when the note is created. This is exactly what I want to happen in my app.

我该怎么做?

推荐答案

棒棒糖的新功能!

活动+片段过渡

album_grid.xml:

album_grid.xml:

<ImageView
    …
    android:transitionName="@string/transition_album_cover" />

album_details.xml:

album_details.xml:

<ImageView
    …
    android:transitionName="@string/transition_album_cover" />

Java:

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());

这篇关于如何扩展CardViews以显示更多细节,例如Google Keep卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 02:28
查看更多