A1 ………… Color 类
A2 ………… Log 类
A3 ………… KeyEvent 类
A4 ………… MotionEvent 类
A5 ………… Uri 类
A6 ………… CheckBox 类
A7 ………… ProgressBar 类
A8 ………… ListView 类
package: android.view.animation
D1 ………… Animation 类
D2 ………… AnimationSet 类
D3 ………… AlphaAnimation 类
D4 ………… RotateAnimation 类
D5 ………… ScaleAnimation 类
D6 ………… TranslateAnimation 类
D7 ………… ProgressBar 类
D8 ………… ListView 类
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A1个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 定义了默认的颜色及一些方法.
java.lang.Object
↳ java.lang.Boolean
2. Color Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A2个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. LogCat 中显示的日志, 可以自定义输出.
java.lang.Object
↳ android.util.Log
2. Log Methods:
※ tag 一般设置为一个常量, 一般为 Activity 的名称.
private static final String TAG = "MyActivity";
将想要传递的内容写在 msg 的参数中, 然后在 LogCat 中通过提取 tag, 并过滤 "MyActivity" 来查看.
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A3个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. Object used to report key and button events.
java.lang.Object
↳ android.view.InputEvent
↳ android.view.KeyEvent
2. KeyEvent Constants:
3. KeyEvent Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A4个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. Object used to report movement (mouse, pen, finger, trackball) events.
java.lang.Object
↳ android.view.InputEvent
↳ android.view.MotionEvent
2. MotionEvent Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A5个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. Immutable URI reference.
java.lang.Object
↳ android.net.Uri
2. MotionEvent Methods:
※ 参考:android之Uri的常用几个例子
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A6个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. The interface that apps use to talk to the window manager.
android.view.WindowManager
WindowManager wm = getWindowManager();
Display d = wm.getDefaultDisplay();
2. WindowManager Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A7个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. Provides information about the display size and density.
java.lang.Object
↳ android.view.Display
2. Display Methods:
Point point = new Point(); Display d = wm.getDefaultDisplay(); d.getSize(point); Log.d("Orientation", "getSize - Width" + point.x); //宽度 Log.d("Orientation", "getSize - Height" + point.y); //高度
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D1个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 动画抽象类.
2. Animation Methods:
3. Animation Constants:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D2个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 动画集合.
2. AnimationSet Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D3个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 透明渐变的动画.
构造函数:AlphaAnimation(float fromAlpha, float toAlpha):1f 为不透明, 0f 为完全透明.
2. AlphaAnimation Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D4个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 旋转的动画.
2. RotateAnimation Constructors:
3. RotateAnimation Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D5个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 缩放的动画.
2. ScaleAnimation Constructs:
3. ScaleAnimation Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D6个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 移动的动画.
2. TranslateAnimation Constructs:
3. TranslateAnimation Methods:
举例:直接建立动画
1 public class MainActivity extends Activity { 2 private ImageView imageView = null; 3 private Button rotateButton = null; 4 5 public void onCreate(Bundle savedInstanceState) { 6 super.onCreate(savedInstanceState); 7 setContentView(R.layout.main); 8 imageView = (ImageView) findViewById(R.id.imageViewId); 9 10 rotateButton = (Button) findViewById(R.id.rotateButtonId); 11 rotateButton.setOnClickListener(new RotateButtonListener()); 12 } 13 14 private class RotateButtonListener implements OnClickListener { 15 public void onClick(View view) { 16 AnimationSet animationSet = new AnimationSet(true); 17 RotateAnimation rotateAnimation = new RotateAnimation(0, 360, 18 Animation.RELATIVE_TO_PARENT, 0.5f, 19 Animation.RELATIVE_TO_SELF, 0.5f); 20 rotateAnimation.setDuration(5000); 21 animationSet.addAnimation(rotateAnimation); 22 imageView.startAnimation(animationSet); 23 } 24 } 25 }
举例:通过 *.xml 文件批量建立动画
res/anim/alpha.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <set xmlns:android="http://schemas.android.com/apk/res/android" 3 android:interpolator="@android:anim/accelerate_interpolator"> 4 <alpha 5 android:fromAlpha="1.0" 6 android:toAlpha="0.0" 7 android:startOffset="500" 8 android:duration="500" /> 9 </set>
res/anim/rotate.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <set xmlns:android="http://schemas.android.com/apk/res/android" 3 android:interpolator="@android:anim/accelerate_interpolator"> 4 <rotate android:fromDegrees="0" 5 android:toDegrees="360" 6 android:pivotX="50%" 7 android:pivotY="50%" 8 android:duration="5000" /> 9 </set>
res/anim/scale.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <set xmlns:android="http://schemas.android.com/apk/res/android" 3 android:interpolator="@android:anim/accelerate_interpolator"> 4 <scale android:fromXScale="1.0" 5 android:toXScale="0.0" 6 android:fromYScale="1.0" 7 android:toYScale="0.0" 8 android:pivotX="50%" 9 android:pivotY="50%" 10 android:duration="2000" /> 11 </set>
res/anim/translate.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <set xmlns:android="http://schemas.android.com/apk/res/android" 3 android:interpolator="@android:anim/accelerate_interpolator"> 4 <translate 5 android:fromXDelta="50%" 6 android:toXDelta="100%" 7 android:fromYDelta="0%" 8 android:toYDelta="100%" 9 android:duration="2000" /> 10 </set>
主函数调用如下.
1 public class MainActivity extends Activity { 2 /** Called when the activity is first created. */ 3 private ImageView imageView = null; 4 private Button rotateButton = null; 5 private Button scaleButton = null; 6 private Button alphaButton = null; 7 private Button translateButton = null; 8 9 public void onCreate(Bundle savedInstanceState) { 10 super.onCreate(savedInstanceState); 11 setContentView(R.layout.main); 12 imageView = (ImageView) findViewById(R.id.imageViewId); 13 14 rotateButton = (Button) findViewById(R.id.rotateButtonId); 15 rotateButton.setOnClickListener(new RotateButtonListener()); 16 17 scaleButton = (Button) findViewById(R.id.scaleButtonId); 18 scaleButton.setOnClickListener(new ScaleButtonListener()); 19 20 alphaButton = (Button) findViewById(R.id.alphaButtonId); 21 alphaButton.setOnClickListener(new AlphaButtonListener()); 22 23 translateButton = (Button) findViewById(R.id.translateButtonId); 24 translateButton.setOnClickListener(new TranslateButtonListener()); 25 } 26 27 private class RotateButtonListener implements OnClickListener { 28 public void onClick(View view) { 29 Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.rotate); 30 imageView.startAnimation(animation); 31 } 32 } 33 34 private class ScaleButtonListener implements OnClickListener { 35 public void onClick(View view) { 36 Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.sacle); 37 imageView.startAnimation(animation); 38 } 39 } 40 41 private class AlphaButtonListener implements OnClickListener { 42 public void onClick(View view) { 43 //使用AnimationUtils装载动画设置文件 44 Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.alpha); 45 imageView.startAnimation(animation); 46 } 47 } 48 49 private class TranslateButtonListener implements OnClickListener { 50 public void onClick(View view) { 51 Animation animation = (Animation) AnimationUtils.loadAnimation(MainActivity.this, R.anim.translate); 52 imageView.startAnimation(animation); 53 } 54 } 55 }