Call, busy two days this, find a variety of information, barely realize my function, this also need to improve, threading knowledge not learned how much, get threading UI has a variety of bugs, helpless. Just skip the first one and have time to come back for a moment.
Body ————
To implement the start animation, there are two methods, one is defined with an XML file, and the second is implemented in Java.
In the XML animation, there are four basic animations, such as the piece description
More advanced XML animations can be combined using these four types
Please click this: XML animating UI
Method procedures for using XML animations:
The first step is to create a new Anim folder in Res, and then write an XML animation file inside it,
Step two, load the resource file
The model code is as follows, change the back of the r.anin.xxx
Animation animation=animationutils.loadanimation (this, r.anim.fade_in);
Step three, assign an animation to a control
First.startanimation (animation);
Ps:
- First is a ImageView
- This method will put an error in the thread run () method, I do not understand the threads, so I can not find a solution
In addition, generally we are to add listeners to the animation, define the behavior before the start of the animation, the behavior of the animation after the bad, and the behavior of the end of the animation
The beginning of the animation generally after the jump to the app main screen activity, with intent intent to jump activity
Don't forget to declare an activity in Androidmainfest.
Animation.setanimationlistener (Animationlistener);
After setting the listener method, do not forget
Use the Java method for animating:
The first step, new animation object
Alphaanimation alphaanimation = new Alphaanimation (0.0f, 1.0f);//transparency from 0.0 (fully transparent) to 1.0 (completely opaque)
The above code is to achieve the fade effect, extrapolate, the other here is not much to say
The second step is to set the related properties for the object,
Alphaanimation.setduration (3000);//Set the animation duration to 3salphaanimation.setfillafter (true);//Set the current state after the animation is finished
Of course not only these two properties, but commonly used in these two, other words, Baidu Bar
Step three, assign animations to controls
First.startanimation (alphaanimation);
PS: Parameter is the object name above
Finally, attach reference: Custom Control Trilogy
Android Intro Animation