0

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);
Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
Pull
  • 2,236
  • 2
  • 16
  • 32

2 Answers2

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.

Pull
  • 2,236
  • 2
  • 16
  • 32
1

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.

Tony Allevato
  • 6,429
  • 1
  • 29
  • 34
  • I wanted to ask you how you found the detail information about the XE21, because usually I search here but there is nothing technical: https://support.google.com/glass/answer/6088192?hl=en&ref_topic=6082760. (you seems to be a Google Glas developer so I get it, but I am wondering if there is a better source of information) – Pull Sep 09 '14 at 08:27
  • 1
    The best place to find a summary of the latest API changes is in our [release notes](https://developers.google.com/glass/release-notes). – Tony Allevato Sep 09 '14 at 16:42