One: Animation effect
Method One: Animation effect with Alphaanimation class, directly add
Alphaanimation AA = new alphaanimation (0,1); Set the transparency aa.setduration (+); Set the time view.startanimation (AA);
Method Two: Apply XML method
Create an XML for Aa.xml file
<?xml version= "1.0" encoding= "Utf-8"? ><alpha xmlns:android= "Http://schemas.android.com/apk/res/android" android:fromalpha= "0" android:toalpha= "1" android:duration= " ></alpha>"
Finally in the reference
Findviewbyid (R.id.btnanimme). Setonclicklistener (New View.onclicklistener () { @Override public void OnClick (View view) {// Alphaanimation AA = new alphaanimation (0,1);// aa.setduration (+);// view.startanimation (AA); Enable View.startanimation (Animationutils.loadanimation (Getapplicationcontext (), R.ANIM.AA)); }
Second: rotation effect
Method One: Directly with the Rotateanimation class
ra = new Rotateanimation (0,360);// RA = new Rotateanimation (0,360,100,50);//Rotate Ra by a point = new Rotateanimation (0,360, animation.relative_to_self,0.5f,animation.relative_to_self,0.5f);//rotate by center point Findviewbyid (R.id.btnrotateme). Setonclicklistener (New View.onclicklistener () { @Override public Void OnClick (view view) { view.startanimation (RA); } });
Way two: Referencing XML file mode
Create an XML file Aa.xml
<?xml version= "1.0" encoding= "Utf-8"? ><rotate xmlns:android= "Http://schemas.android.com/apk/res/android" android:fromdegrees= "0" android:todegrees= "android:duration=" android:pivotx= "50%"/ /Set the x-axis of the rotation center point to be the midpoint (in percent), if the number and pixel android:pivoty= "50"//Set the y-axis of the rotation center point to be the midpoint (in percent), and for the number and pixel point ></rotate>
Last Call
Findviewbyid (R.id.btnanimme). Setonclicklistener (New View.onclicklistener () { @Override public void OnClick (View view) { view.startanimation (animationutils.loadanimation (MAINACTIVITY.THIS,R.ANIM.AA)); }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android View animation effect-transparency effect, rotation effect