ImageButtonを押して指を下に置くと見えなくなり、指を離すと再び見えるようになります。
しかし、ボタンを押して指を下に向けているときに、ボタンをボタンから離して持ち上げると、再び表示されなくなります。
コードは次のようになります
final ImageButton b=(ImageButton)findViewById(R.id.timer_btn);
b.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_UP:
b.setVisibility(View.VISIBLE);
Log.w("app", "Action up");
return true;
case MotionEvent.ACTION_DOWN:
b.setVisibility(View.INVISIBLE);
Log.w("app", "Action down");
}
return false;
}
});
使ってみました
case MotionEvent.ACTION_OUTSIDE:
b.setVisibility(View.VISIBLE);
Log.w("app", "Action outside");
}
しかし、それは機能しません、それがボタンの外側にあるか内側にあるかに関係なく呼び出されます