简体   繁体   中英

Google Glass: How to animate change card in cardScrollView?

Is it possible to do change programmatically the current card to a new position with a slide animation ?

The following code only teleport to the chosen position :

cardScrollView.setSelection(cardScrollView.getSelectedItemPosition() - 1);

I didn't find a way to simulate a slide animation like the one when you slide manually, but this solution was good enough for me :

cardScrollView.setSelection(cardScrollView.getSelectedItemPosition() - 1);
cardScrollView.startAnimation(AnimationUtils.makeInAnimation(cardScrollView.getContext(), true));

Your new slide will have a slide animation from the right or the left depending if the second argument if true or false.

Perfect timing! This was just added to the GDK in XE21. Check out the new CardScrollView.animate method, which allows you to slide to an existing card as well as insert and delete cards with animations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM