public boolean onTouch(View v, MotionEvent event) {
final int DELAY = 100;
if(event.getAction() == MotionEvent.ACTION_UP) {
RelativeLayout fondo = (RelativeLayout) findViewById(R.id.background);
ColorDrawable f = new ColorDrawable(0xff00ff00);
ColorDrawable f2 = new ColorDrawable(0xffff0000);
ColorDrawable f3 = new ColorDrawable(0xff0000ff);
ColorDrawable f4 = new ColorDrawable(0xff0000ff);
AnimationDrawable a = new AnimationDrawable();
a.addFrame(f, DELAY);
a.addFrame(f2, DELAY);
a.addFrame(f3, DELAY);
a.addFrame(f4, DELAY);
a.setOneShot(false);
fondo.setBackgroundDrawable(a); // This method is deprecated in API 16
// fondo.setBackground(a); // Use this method if you're using API 16
a.start();
}
return true;
}
我想代替上面的ontouch布尔值,我的背景在查看和不被触摸时会改变颜色。例如按一个按钮转到新的布局,然后不触摸屏幕就开始闪烁
最佳答案
仍然需要更加明确地为我们提供帮助,而不是完全确定您要做什么。
如果我理解正确,您想按一个按钮,然后在屏幕闪烁的位置打开新布局?