Android Animation-property Animation

Source: Internet
Author: User

Property Animation attribute animation, this was introduced in Android 3.0.
Property animation It changes the value of the object property, applies to any object, and tween animation changes the effect of painting, and its attribute value is unchanged.

Objectanimator: Changing the property value of an object
How to use:
Objectanimator translationright = objectanimator.offloat (M_tv, "X", width);
Translationright.setduration (1500);
Translationright.start ();
This is a translational effect, objectanimator.offloat (M_TV, "X", width); The first argument is: The object's second argument: The property of the object, the attribute must have the corresponding getx () and the Setx () method, and the third parameter: the value of a mutable parameter
If you write only a value, then the default from the current value to fill the value, if you fill in more than the order in which the corresponding changes,
Setduration (): Set run time, start (): On

Animatorset: The effect of multiple objectanimator is performed or executed in sequence
Objectanimator translationright = objectanimator.offloat (M_tv, "X", width);
Objectanimator translationleft = objectanimator.offloat (M_tv, "X", 0f);
Objectanimator Translationdown = objectanimator.offloat (M_tv, "Y", height);
Objectanimator translationup = objectanimator.offloat (M_tv, "Y", 0);
Animatorset as = new Animatorset ();
As.play (Translationright). before (Translationleft);
As.play (Translationright). with (Translationdown);
As.play (Translationleft). with (Translationup);
Paly () with () before () after () setting the order of Execution start () on

Please refer to the following code for more information: http://www.open-open.com/lib/view/open1329994048671.html
Valueanimator,typeevalutors,timeinterplator,keyframes



Some sample code:

<span style= "FONT-FAMILY:SIMSUN;FONT-SIZE:18PX;" ><?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/ Res/android "    android:layout_width=" match_parent "    android:layout_height=" match_parent "    android:o rientation= "vertical" >    <imageview        android:id= "@+id/image" android:layout_width= "Wrap_content        "        android:layout_height=" wrap_content "        android:background=" @drawable/girl "/>    <edittext        android:id= "@+id/edit_text"        android:layout_width= "match_parent"        android:layout_height= "Wrap_ Content "        android:layout_margin=" 5DP "/></linearlayout></span>


implementation:
<span style= "FONT-FAMILY:SIMSUN;FONT-SIZE:18PX;" >private void Initimageanimationset () {ImageView image = (ImageView) Findviewbyid (r.id.image); Objectanimator Oboutx = Objectanimator.offloat (Image, "X", +); Objectanimator obouty = objectanimator.offloat (image, "Y", +); O Bjectanimator Obinx = objectanimator.offloat (image, "X", 0); Objectanimator obiny = objectanimator.offloat (image, "Y", 0) ; final Animatorset set = new Animatorset (); Set.play (OBOUTX). with (Obouty), Set.play (Obinx). with (Obiny); Set.play ( OBOUTX). before (Obinx); Image.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View v) { Set.start ();}});} /** * Objectanimator uses */private void Initeditobjectanimator () {EditText EDT = (EditText) Findviewbyid (R.id.edit_text); Final Objectanimator translationright = objectanimator.offloat (EDT, "X", 0, -10, Max, -5, 1, -3, 0); Transla Tionright.setduration (Edt.addtextchangedlistener), new Textwatcher () {@Overridepublic void ontextchanged ( Charsequence S, int start, int before,int count) {} @Overridepublic void beforetextchanged (charsequence s, int start, int count,int after) {} @Overridepublic void aftertextchanged (Editable s) {if (Textutils.isempty (s.tostring ())) {Translationright.start ();}});} </span>


Case code Download:

:







   

Android Animation-property Animation

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.