简体   繁体   中英

ImageView onTouchListener with Gallery

I want to add to the ImageView the pinch feature. So I extended the ImageView and I implemented the OnTouchListener interface. The ImageView is clickable. The feature itsel works, but when I use the custom ImageView with the Gallery widget, the gallery does not swipe. If I set focusable and clickable to false, gallery swipe. How can I let they work together?

Code for the custom ImageView

    public class Custom6 extends ImageView implements OnTouchListener {


        public Custom6(Context context) {
            super(context);
            setClickable(true);
            setScaleType(ScaleType.MATRIX);
            setOnTouchListener(this);
        }

        public Custom6(Context context, AttributeSet attrs,
                int defStyle) {
            super(context, attrs, defStyle);
            setClickable(true);
            setScaleType(ScaleType.MATRIX);
            setOnTouchListener(this);
        }

        public Custom6(Context context, AttributeSet attrs) {
            super(context, attrs);
            setClickable(true);
            setScaleType(ScaleType.MATRIX);
            setOnTouchListener(this);
        }

       public boolean onTouch(View v, MotionEvent event) {
           return true;
       }

在ontouch列表器中返回false,然后尝试我希望它会起作用...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM