1

在我的活动中,我有一个ImageView. 它具有捏缩放功能。

当我触摸时,ImageView我会显示缩略图布局。

但是当我捏ImageView缩略图布局显示时。我想阻止它?

我该怎么做?

这是我显示缩略图布局的代码:

image.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        Boolean openThumbnails=true;
        if(event.getAction() == MotionEvent.ACTION_UP && openThumbnails){
            Log.e("event.getAction()", "MotionEvent.ACTION_UP");
            if(thumbnailsLayout.getVisibility()==View.GONE && header.getVisibility()==View.GONE && openThumbnails){
                thumbnailsLayout.setVisibility(View.VISIBLE);
                header.setVisibility(View.VISIBLE);
                header.bringToFront();
            }
            else{
                thumbnailsLayout.setVisibility(View.GONE);
                header.setVisibility(View.GONE);
            }
        }
        else if(event.getAction() == MotionEvent.ACTION_DOWN){
            Log.e("event.getAction()", "MotionEvent.ACTION_DOWN");
            return true;
        }
        else if(event.getAction()==MotionEvent.ACTION_MOVE){
            Log.e("openThumbnails before", openThumbnails.toString());
            openThumbnails=false;        
            Log.e("openThumbnails and after", openThumbnails.toString());
        }
        return false;
    }
});
4

1 回答 1

0

你的 openThumbnails 总是正确的。您在方法开始时设置它。您将 openThumbnail 设置为 true 的每个触摸事件(例如 Action_up、action_move)。这就是为什么你总是展示它。

image.setOnTouchListener(new OnTouchListener() {
Boolean openThumbnails=true;
                    @Override
                    public boolean onTouch(View v, MotionEvent event) {

                        if(event.getAction() == MotionEvent.ACTION_UP && openThumbnails){
                            Log.e("event.getAction()", "MotionEvent.ACTION_UP");
                            if(thumbnailsLayout.getVisibility()==View.GONE && header.getVisibility()==View.GONE && openThumbnails){
                                thumbnailsLayout.setVisibility(View.VISIBLE);
                                header.setVisibility(View.VISIBLE);
                                header.bringToFront();
                            }
                            else{
                                thumbnailsLayout.setVisibility(View.GONE);
                                header.setVisibility(View.GONE);
                            }
                        }
                        else if(event.getAction() == MotionEvent.ACTION_DOWN){
                            Log.e("event.getAction()", "MotionEvent.ACTION_DOWN");
                            return true;
                        }
                        else if(event.getAction()==MotionEvent.ACTION_MOVE){
                            Log.e("openThumbnails before", openThumbnails.toString());
                            openThumbnails=false;       
                            Log.e("openThumbnails and after", openThumbnails.toString());
                        }
                        return false;
                    }
                });
于 2013-11-06T14:11:06.937 回答