I'm trying to figure out how I could make a similar layout as in Google plus timeline view. There's an animation while scrolling in timeline and I really like it. Any idea how to do that?
问题:
回答1:
You need to set a TranslateAnimation to the view and that would do the trick for you.
TranslateAnimation translateAnim = new TranslateAnimation(200, 0, 0, 0 );
//Use (0, 0, 200, 0 ) if you would like to animate this in a mobile device rather than a tab
listView.clearAnimation();
translateAnim.setDuration(500);
translateAnim.setFillBefore(true);
listView.startAnimation(translateAnim);
Hope this helps :)
回答2:
I would check out the carousel example code provide by google http://code.google.com/p/renderscript-examples/wiki/Carousel
Essentially what this does is creates a series of tiles that can be textured by any image you please. The code is set up out of the box to do a cylindrical carousel from the outside but you can move the view point and even make it flat as in the g+ example if you so chose.
A note of caution, as of Jellybean (4.1) Google has deprecated the graphics components of renderscript. We have begun the process of moving everything over from renderscript to openGL at our company, so be sure to evaluate if making new code with a deprecated API makes sense for you particular usage.