我为imageView写了一个onTouchListner():
final ImageView image = (ImageView) findViewById(R.id.but_kh);
final ImageView hover = (ImageView) findViewById(R.id.hov_but);
image.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
image.setVisibility(0);
hover.setVisibility(100);
return false;
}
});
如您所见,我设置了图像0的可见性,但我不知道如何在图像悬停完成时将其设为100,这意味着我希望在悬停后将这两个图像更改为可视性哦:
image.setVisibility(100);
hover.setVisibility(0);
提前感谢,
答案 0 :(得分:2)
image.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
image.setVisibility(0);
hover.setVisibility(100);
break;
case MotionEvent.ACTION_UP:
image.setVisibility(100);
hover.setVisibility(0);
break;
}
return true;
}
});