android - How to animate image in RecyclerView's item? -
gmail (supposedly using recyclerview) in inbox displays items contain images , text. when given item selected/tapped triggers animation of image 'transitions' checkbox.
i've seen examples of animations apply whole items (viewholders). however, have no idea how gmail app
able animate images only.
any appreciated.
if there image in recycler view item , want start new activity animating image when recycler item clicked, add same transition name image view in recycler item image view in next activity.
<imageview android:layout_width="100dp" android:layout_height="120dp" android:layout_margintop="10dp" android:id="@+id/image" android:scaletype="fitcenter" android:transitionname="bookimage"/>
then through onclick listener start activity using activity options compat animate image.
itemview.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { intent intent = new intent(mactivity, detailactivity.class); // define view animation start imageview imagestart = (imageview) v.findviewbyid(r.id.image); activityoptionscompat options = activityoptionscompat.makescenetransitionanimation (this, imagestart, imagestart.gettransitionname()); activitycompat.startactivity(mactivity, intent, options.tobundle()); } });
you can add multiple elements animate in activityoptionscompat
Comments
Post a Comment