Skip to content Skip to sidebar Skip to footer

How Do I Expand Cardviews To Show More Detail Like Google Keep Cards?

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 a

Solution 1:

New in Lollipop!

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:

<ImageViewandroid:transitionName="@string/transition_album_cover" />

album_details.xml:

<ImageViewandroid:transitionName="@string/transition_album_cover" />

Java:

AlbumActivity.java
Intentintent=newIntent();
StringtransitionName= getString(R.string.transition_album_cover);
…
ActivityOptionsCompatoptions=
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.

Post a Comment for "How Do I Expand Cardviews To Show More Detail Like Google Keep Cards?"