Created
July 8, 2015 16:06
-
-
Save ralphilius/fde5b8f9e25a7a85855f to your computer and use it in GitHub Desktop.
ImageView Transitions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<RelativeLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"> | |
<ImageView | |
android:id="@+id/cardImage" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:scaleType="centerCrop" | |
android:transitionName="cardImage" | |
android:src="@drawable/smiley"/> | |
</RelativeLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
View cardImage = (ImageView) findViewById(R.id.cardImage); | |
cardImage.setTransitionName("cardImage"); | |
ImageView cardImage = (ImageView) findViewById(R.id.cardImage); | |
cardImage.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
//This is where the magic happens. makeSceneTransitionAnimation takes a context, view, a name for the target view. | |
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(MaterialActivity.this, cardImage, "cardImage"); | |
Intent intent = new Intent(OriginalActivity.this, DetailActivity.class); | |
startActivity(intent, options.toBundle()); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<style name="AppTheme" parent="android:Theme.Material.Light"> | |
<!-- enable window content transitions --> | |
<item name="android:windowContentTransitions">true</item> | |
<!-- enable overlapping of exiting and entering activities--> | |
<item name="android:windowAllowEnterTransitionOverlap">true</item> | |
<item name="android:windowAllowReturnTransitionOverlap">true</item> | |
</style> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From: http://www.willowtreeapps.com/blog/material-world-animating-l-shared-view-activity-animations/
and https://github.com/willowtreeapps/MaterialGirl