private class MyView extends View
{
private Bitmap bitmap;
public MyView(Context context)
{
super(context);
InputStream is =getResources().openRawResource(R.drawable.image);
bitmap = BitmapFactory.decodeStream(is);
setBackgroundColor(Color.WHITE);
}
@Override
protected void onDraw(Canvas canvas)
{
Paint paint = new Paint();
paint.setAlpha(alpha);
canvas.drawBitmap(bitmap, new Rect(0, 0, bitmap.getWidth(), bitmap
.getHeight()), new Rect(10, 10, 310, 235), paint);
}
}
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser)
{
alpha = progress;
setTitle("alpha:" + progress);
myView.invalidate();
}
<?xml version="1.0" encoding="utf-8"?> <alpha xmlns:android="http://schemas.android.com/apk/res/android" android:fromAlpha="1.0" android:toAlpha="0.0" android:repeatCount="infinite" android:duration="2000"> </alpha>
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public
class AlphaActivity extends Activity {
/**显示动画的ImageView**/
ImageView mImageView = null;
/**透明动画**/
Animation mAnimation = null;
@Override
public
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.translate);
/**拿到ImageView对象**/
mImageView = (ImageView)findViewById(R.id.imageView);
/**加载透明动画**/
mAnimation = AnimationUtils.loadAnimation(this, R.anim.alpha);
/**播放透明动画**/
mImageView.startAnimation(mAnimation);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有