Android 小项目之--消息、线程、动画显示图片
2010-06-04 14:29:00 来源:WEB开发网@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myImageView=(ImageView)findViewById(R.id.ImageView01);
myAnimationAlpha=new AlphaAnimation(0.1f, 1.0f);
myAnimationAlpha.setDuration(3000);
myAnimationScale=new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
myAnimationScale.setDuration(3000);
myAnimationTranslate=new TranslateAnimation(30.0f, -80.0f, 30.0f, 300.0f);
myAnimationTranslate.setDuration(3000);
myAnimationRotate=new RotateAnimation(0.0f, +350.0f,
Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF, 0.5f);
myAnimationRotate.setDuration(3000);
// myLinearLayout.setBackgroundColor(Color.WHITE);
myHandler=new Handler()
{
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
switch (msg.what) {
case testHandler.my_key:
switch (a) {
case 0:
myImageView.startAnimation(myAnimationAlpha);
break;
case 1:
myImageView.startAnimation(myAnimationScale);
break;
case 2:
myImageView.startAnimation(myAnimationTranslate);
break;
case 3:
myImageView.startAnimation(myAnimationRotate);
break;
default:
break;
}
myImageView.setImageResource(myImage[a-1]);
myImageView.setScaleType(ImageView.ScaleType.FIT_XY);
//myImageView.setLayoutParams(new LayoutParams(300, 200));
if(a==myImage.length)
{
a=0;
}
break;
default:
break;
}
更多精彩
赞助商链接