android 对View的延时更换内容

1、当ImageView按下时能够跟换一张按下效果的图片进行显示,使用postDelayed便可以让view在规定时间后执行run()中的内容ide

img.setImageResource(R.drawable.pzt_up_press);      
img.postDelayed(new Runnable() {
@Override
public void run() {
  img.setImageResource(R.drawable.pzt_up_nomal);
  }
}, 200);post

2、让TextView字体显示小一号后,间隔规定时间显示为正常大小:字体

text.setTextSize(TypedValue.COMPLEX_UNIT_SP,16);      //使用TypedValue后不用本身进行字体转换
text.postDelayed(new Runnable() {
@Override
public void run() {
text.setTextSize(TypedValue.COMPLEX_UNIT_SP,18);
}
}, 500);图片

相关文章
相关标签/搜索