Android.hack.02_animations

Source: Internet
Author: User

#01 # TextView and ImageView

  TextView and ImageView switch stutter, in order to achieve better switching, can be implemented with animation, the system comes with the Textviewswitcher and Imageviewswitcher, which set custom animation, you can use the following demo:

PrivateTextswitcher Mtextswitcher;
@Override Public voidonCreate (Bundle savedinstancestate) {
Super. OnCreate (savedinstancestate); Setcontentview (R.layout.main); Animation in= Animationutils.loadanimation ( This, Android.  R.ANIM.FADE_IN); Animation out= Animationutils.loadanimation ( This, Android.  R.anim.fade_out); Mtextswitcher=(Textswitcher) Findviewbyid (R.id.your_textview); Mtextswitcher.setfactory (NewViewfactory () {
@Override PublicView Makeview () {TextView T=NewTextView (youractivity. This); t.setgravity (Gravity.center);
21stAdding eye candy to your viewgroup ' s children
returnt;}); Mtextswitcher.setinanimation (in); Mtextswitcher.setoutanimation (out);}

Reference Link: http://developer.android.com/reference/android/widget/TextSwitcher.html

Http://developer.android.com/guide/topics/graphics/view-animation.html

#02 # Add animation-----to ViewGroup's children Layoutanimationcontroller

Examples are the best interpretations:

Mlistview = (ListView) Findviewbyid (r.id.my_listview_id);

Animationset set = new Animationset (true);
Animation Animation = new Alphaanimation (0.0f, 1.0f);
Animation.setduration (50);
Set.addanimation (animation);
Animation = new Translateanimation (animation.relative_to_self, 0.0f,
Animation.relative_to_self, 0.0f, Animation.relative_to_self,
-1.0f, Animation.relative_to_self, 0.0f);
Animation.setduration (100);
Set.addanimation (animation);
Layoutanimationcontroller controller = new Layoutanimationcontroller (
Set, 0.5f);
Create Layoutanimationcontroller
and delay between animations. Mlistview.setlayoutanimation (Controller);

Reference Link: http://developer.android.com/reference/android/view/animation/LayoutAnimationController.html
--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------

#03 # Android uses Nineoldandroids to achieve gorgeous ListView swipe left and right to delete item effect

Nine Old androids can also be achieved, the image of the zoom effect, with the official API inside the image of the same effect. That is: Ken Burns special effects,

The more detailed demo, has been translated by someone:

: http://blog.csdn.net/manoel/article/details/39164225

An Android control that implements the effect of Ken Burns effect picture display effect. Ken Burns effect is a picture that moves slowly over the page or zooms out before switching, and then slowly switching over. This effect makes every still picture have a dynamic effect feeling. Similar effects are often visible in electronic albums, or in the processing of static images in movie videos.

Project Address Https://github.com/flavioarfaria/KenBurnsView

Usage:

The simplest use is to put the jar file provided in the project directly, and then add it in the XML:

12345 <com.flaviofaria.kenburnsview.KenBurnsView    <span id="1_nwp" style="width: auto; height: auto; float: none;"><a id="1_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Ejcodecraeer%2Ecom%2Fa%2Fanzhuokaifa%2Fandroidkaifa%2F2014%2F0920%2F1698%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=01072140_cpr&k=android&k0=android&kdi0=8&k1=%B6%AF%BB%AD&kdi1=8&k2=%B5%E7%D7%D3%CF%E0%B2%E1&kdi2=8&sid=861a9a46d40c70b6&ch=0&tu=u1921070&jk=015869c8e072c03f&cf=29&rb=0&fv=16&stid=9&urlid=0&luki=1&seller_id=1&di=128" target="_blank" mpid="1" style="text-decoration: none;"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">android</span></a></span>:id="@+id/image"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:src="@drawable/your_drawable" />

Advanced usage:

1. Set Listener:

123456789 kenburnsview KBV = (kenburnsv Iew) Findviewbyid (r.id.image); kbv.settransitionlistener ( new transitionlistener () { &NBSP;&NBSP;&NBSP;&NBSP; Code class= "JS plain" > @Override &NBSP;&NBSP;&NBSP;&NBSP; public void Ontransitionstart (Transition Transition) {       }      @Override &NBSP;&NBSP;&NBSP;&NBSP; public void Ontransitionend (Transition Transition) {       } });

2. You can use Kbv.pause () and kbv.resume() pause and resume animations.

3. You can set the animation interpolation and excessive time:

12 RandomTransitionGenerator generator = newRandomTransitionGenerator(duration, interpolator);kbv.setTransitionGenerator(generator);

 

  

  

Android.hack.02_animations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.