首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 平面设计 > 图形图像 >

ImageView淡入淡出成效

2012-09-28 
ImageView淡入淡出效果?public class FadeInAndOut extends Activity {private int intCounter 0privat

ImageView淡入淡出效果

?

public class FadeInAndOut extends Activity {private int intCounter = 0;private Handler mHandler = new Handler();private ImageView mImageView01;public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.fade_in_out);mImageView01 = (ImageView) findViewById(R.id.imageView1);mImageView01.setImageResource(R.drawable.img1);mImageView01.setAlpha(0);mHandler.post(fadeInTask);}/* 设定ImageView的透明度渐显出来 */private Runnable fadeInTask = new Runnable() {public void run() {intCounter = intCounter + 1;mImageView01.setAlpha(intCounter * 15);if(intCounter == 17)mHandler.postDelayed(fadeOutTask, 50);else mHandler.postDelayed(fadeInTask, 50);}};/* 设定ImageView的透明度渐暗下去 */private Runnable fadeOutTask = new Runnable() {public void run() {intCounter = intCounter - 1;mImageView01.setAlpha(intCounter * 15);if(intCounter == 0)mHandler.postDelayed(fadeInTask, 50);else mHandler.postDelayed(fadeOutTask, 50);}};}
?

热点排行