2016年2月28日 星期日

Animating:share element

share element
detail explain:

share the same content(same image ,same button,same view….) in different activity.

example :
if we want ot share the weather icon:



Concept.frist we need to set the aim view that have a transaction name,use
in xml
android:transitionName="@string/detail_icon_transition_name"

in program:
settransitionName

when we start the new fragment on new activity,we need to use

for activity:

ActivityOptionsCompat activityOptions =
                   ActivityOptionsCompat.makeSceneTransitionAnimation(this,
                           new Pair<View, String>(vh.mIconView, getString(R.string.detail_icon_transition_name)));
           ActivityCompat.startActivity(this, intent, activityOptions.toBundle());

vh.mIconView is the start view, the string is the aim view’s transaction name.

for fragment:

 <item name="android:windowContentTransitions">true</item>   is must!!!!!!!

a important thing:
It is because some time the data can load after thne UI show,and afterthe transaction aimimation finish,so we can set to postpone the UI transaction aimimation show,after the data load finish.

supportPostponeEnterTransition
should use when the activity created



supportStartPostponedEnterTransition
use when the data load finish.like onLoadFinish in the asyncloader.

here is the answer code: