当前位置: 首页>>代码示例>>Java>>正文


Java ImageView.setOnTouchListener方法代码示例

本文整理汇总了Java中android.widget.ImageView.setOnTouchListener方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.setOnTouchListener方法的具体用法?Java ImageView.setOnTouchListener怎么用?Java ImageView.setOnTouchListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ImageView的用法示例。


在下文中一共展示了ImageView.setOnTouchListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cleanup

import android.widget.ImageView; //导入方法依赖的package包/类
public void cleanup() {
    if(null != this.mImageView) {
        ImageView imageView = (ImageView)this.mImageView.get();
        if(null != imageView) {
            ViewTreeObserver observer = imageView.getViewTreeObserver();
            if(null != observer && observer.isAlive()) {
                observer.removeGlobalOnLayoutListener(this);
            }

            imageView.setOnTouchListener((View.OnTouchListener)null);
            this.cancelFling();
        }

        if(null != this.mGestureDetector) {
            this.mGestureDetector.setOnDoubleTapListener((GestureDetector.OnDoubleTapListener)null);
        }

        this.mMatrixChangeListener = null;
        this.mPhotoTapListener = null;
        this.mViewTapListener = null;
        this.mImageView = null;
    }
}
 
开发者ID:leobert-lan,项目名称:UiLib,代码行数:24,代码来源:PhotoViewAttacher.java

示例2: PhotoViewAttacher

import android.widget.ImageView; //导入方法依赖的package包/类
public PhotoViewAttacher(ImageView imageView) {
	mImageView = new WeakReference<ImageView>(imageView);

	imageView.setOnTouchListener(this);

	mViewTreeObserver = imageView.getViewTreeObserver();
	mViewTreeObserver.addOnGlobalLayoutListener(this);

	// Make sure we using MATRIX Scale Type
	setImageViewScaleTypeMatrix(imageView);

	if (!imageView.isInEditMode()) {
		// Create Gesture Detectors...
		mScaleDragDetector = VersionedGestureDetector.newInstance(
				imageView.getContext(), this);

		mGestureDetector = new GestureDetector(imageView.getContext(),
				new GestureDetector.SimpleOnGestureListener() {

					// forward long click listener
					@Override
					public void onLongPress(MotionEvent e) {
						if (null != mLongClickListener) {
							mLongClickListener.onLongClick(mImageView.get());
						}
					}
				});

		mGestureDetector.setOnDoubleTapListener(this);

		// Finally, update the UI so that we're zoomable
		setZoomable(true);
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:PhotoViewAttacher.java

示例3: PhotoViewAttacher

import android.widget.ImageView; //导入方法依赖的package包/类
public PhotoViewAttacher(ImageView imageView) {
    mImageView = new WeakReference<ImageView>(imageView);
    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer)
        observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(
            imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    try {
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getImageView());
                    }
                    }catch (Exception exception){}
                }
            });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));

    // Finally, update the UI so that we're zoomable
    setZoomable(true);
}
 
开发者ID:yun2win,项目名称:tvConnect_android,代码行数:39,代码来源:PhotoViewAttacher.java

示例4: PhotoViewAttacher

import android.widget.ImageView; //导入方法依赖的package包/类
public PhotoViewAttacher(ImageView imageView) {
	mImageView = new WeakReference<ImageView>(imageView);

	imageView.setOnTouchListener(this);

	mViewTreeObserver = imageView.getViewTreeObserver();
	mViewTreeObserver.addOnGlobalLayoutListener(this);

	// Make sure we using MATRIX Scale Type
	setImageViewScaleTypeMatrix(imageView);

	if (!imageView.isInEditMode()) {
		// Create Gesture Detectors...
		mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

		mGestureDetector = new GestureDetector(imageView.getContext(),
				new GestureDetector.SimpleOnGestureListener() {

					// forward long click listener
					@Override
					public void onLongPress(MotionEvent e) {
						if (null != mLongClickListener) {
							mLongClickListener.onLongClick(mImageView.get());
						}
					}
				});

		mGestureDetector.setOnDoubleTapListener(this);

		// Finally, update the UI so that we're zoomable
		setZoomable(true);
	}
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:34,代码来源:PhotoViewAttacher.java

示例5: getImageView

import android.widget.ImageView; //导入方法依赖的package包/类
private ImageView getImageView(int x, int y) {
    ImageView imageView = new ImageView(context);
    LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    imageView.setLayoutParams(layoutParams);
    imageView.setImageResource(R.drawable.circle);
    imageView.setX(x);
    imageView.setY(y);
    imageView.setOnTouchListener(new TouchListenerImpl());
    return imageView;
}
 
开发者ID:mohammedirfan655,项目名称:document-scanner,代码行数:11,代码来源:PolygonView.java

示例6: cleanup

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Clean-up the resources attached to this object. This needs to be called when the ImageView is
 * no longer used. A good example is from {@link View#onDetachedFromWindow()} or
 * from {@link android.app.Activity#onDestroy()}. This is automatically called if you are using
 */
@SuppressWarnings("deprecation")
public void cleanup() {
    if (null == mImageView) {
        return; // cleanup already done
    }

    final ImageView imageView = mImageView.get();

    if (null != imageView) {
        // Remove this as a global layout listener
        ViewTreeObserver observer = imageView.getViewTreeObserver();
        if (null != observer && observer.isAlive()) {
            observer.removeGlobalOnLayoutListener(this);
        }

        // Remove the ImageView's reference to this
        imageView.setOnTouchListener(null);

        // make sure a pending fling runnable won't be run
        cancelFling();
    }

    if (null != mGestureDetector) {
        mGestureDetector.setOnDoubleTapListener(null);
    }

    // Clear listeners too
    mMatrixChangeListener = null;
    mPhotoTapListener = null;
    mViewTapListener = null;

    // Finally, clear ImageView
    mImageView = null;
}
 
开发者ID:yun2win,项目名称:tvConnect_android,代码行数:40,代码来源:PhotoViewAttacher.java

示例7: PhotoViewAttacher

import android.widget.ImageView; //导入方法依赖的package包/类
public PhotoViewAttacher(ImageView imageView) {
	mImageView = new WeakReference<ImageView>(imageView);

	imageView.setOnTouchListener(this);

	mViewTreeObserver = imageView.getViewTreeObserver();
	mViewTreeObserver.addOnGlobalLayoutListener(this);

	// Make sure we using MATRIX Scale Type
	setImageViewScaleTypeMatrix(imageView);

	if (!imageView.isInEditMode()) {
		// Create Gesture Detectors...
		mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

		mGestureDetector = new GestureDetector(imageView.getContext(),
				new GestureDetector.SimpleOnGestureListener() {

					// forward long click listener
					@Override
					public void onLongPress(MotionEvent e) {
						if(null != mLongClickListener) {
							mLongClickListener.onLongClick(mImageView.get());
						}
					}});

		mGestureDetector.setOnDoubleTapListener(this);

		// Finally, update the UI so that we're zoomable
		setZoomable(true);
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:33,代码来源:PhotoViewAttacher.java

示例8: onFinishInflate

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mAllAppsHandle = (ImageView) findViewById(R.id.all_apps_handle);
    mAllAppsHandle.setImageDrawable(getCaretDrawable());
    mAllAppsHandle.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
    mAllAppsHandle.setOnClickListener(mLauncher);
    mAllAppsHandle.setOnLongClickListener(mLauncher);
    mAllAppsHandle.setOnFocusChangeListener(mLauncher.mFocusHandler);
    mLauncher.setAllAppsButton(mAllAppsHandle);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:12,代码来源:PageIndicatorLineCaret.java

示例9: PhotoViewAttacher

import android.widget.ImageView; //导入方法依赖的package包/类
public PhotoViewAttacher(ImageView imageView) {
    mImageView = new WeakReference<ImageView>(imageView);

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer)
        observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(
            imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getImageView());
                    }
                }
            });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));

    // Finally, update the UI so that we're zoomable
    setZoomable(true);
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:38,代码来源:PhotoViewAttacher.java

示例10: onCreate

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    progressBar = (ProgressBar) findViewById(R.id.progressbar);
    etUsername = (EditText) findViewById(R.id.username);
    etPassword = (EditText) findViewById(R.id.password);
    captcha = (ImageView) findViewById(R.id.captcha);
    checkBox = (CheckBox) findViewById(R.id.checkbox);
    btnLogin = (Button) findViewById(R.id.btn_login);
    selected1 = (ImageView) findViewById(R.id.selected1);
    selected2 = (ImageView) findViewById(R.id.selected2);
    selected3 = (ImageView) findViewById(R.id.selected3);
    selected4 = (ImageView) findViewById(R.id.selected4);
    selected5 = (ImageView) findViewById(R.id.selected5);
    selected6 = (ImageView) findViewById(R.id.selected6);
    selected7 = (ImageView) findViewById(R.id.selected7);
    selected8 = (ImageView) findViewById(R.id.selected8);

    addToList();
    captcha.setOnTouchListener(this);
    btnLogin.setOnClickListener(this);
    registerBus();
    loadData();
    loginInit();

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    density = metrics.density;
}
 
开发者ID:Akari10032,项目名称:12306_Android,代码行数:31,代码来源:LoginActivity.java

示例11: addSelector

import android.widget.ImageView; //导入方法依赖的package包/类
public void addSelector(Drawable drawable, ColorListener colorListener) {
    if(drawable == null || colorListener == null) return;

    final ImageView selectorImage = new ImageView(getContext());
    selectorImage.setImageDrawable(drawable);
    final Selector selector = new Selector(selectorImage, colorListener);

    selector.getSelector().setX(getMeasuredWidth()/2 - selector.getSelector().getWidth()/2);
    selector.getSelector().setY(getMeasuredHeight()/2- selector.getSelector().getHeight()/2);

    FrameLayout.LayoutParams thumbParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    thumbParams.gravity = Gravity.CENTER;

    selectorImage.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            switch (motionEvent.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    swapAlpha(selector);
                    mainSelector = selector;

                    Matrix invertMatrix = new Matrix();
                    palette.getImageMatrix().invert(invertMatrix);

                    float[] mappedPoints = new float[]{motionEvent.getX(), motionEvent.getY()};
                    invertMatrix.mapPoints(mappedPoints);

                    MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, motionEvent.getX(), motionEvent.getY(), 0);
                    dispatchTouchEvent(event);
                    break;
            }
            return false;
        }
    });

    addView(selector.getSelector(), thumbParams);
    swapAlpha(selector);
    selectorList.add(selector);
    mainSelector = selector;
}
 
开发者ID:skydoves,项目名称:ColorPickerView,代码行数:41,代码来源:MultiColorPickerView.java

示例12: cleanup

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Clean-up the resources attached to this object. This needs to be called when the ImageView is
 * no longer used. A good example is from {@link View#onDetachedFromWindow()} or
 * from {@link android.app.Activity#onDestroy()}. This is automatically called if you are using
 * {@link PhotoView}.
 */
@SuppressWarnings("deprecation")
public void cleanup() {
    if (null == mImageView) {
        return; // cleanup already done
    }

    final ImageView imageView = mImageView.get();

    if (null != imageView) {
        // Remove this as a global layout listener
        ViewTreeObserver observer = imageView.getViewTreeObserver();
        if (null != observer && observer.isAlive()) {
            observer.removeGlobalOnLayoutListener(this);
        }

        // Remove the ImageView's reference to this
        imageView.setOnTouchListener(null);

        // make sure a pending fling runnable won't be run
        cancelFling();
    }

    if (null != mGestureDetector) {
        mGestureDetector.setOnDoubleTapListener(null);
    }

    // Clear listeners too
    mMatrixChangeListener = null;
    mPhotoTapListener = null;
    mViewTapListener = null;

    // Finally, clear ImageView
    mImageView = null;
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:41,代码来源:PhotoViewAttacher.java

示例13: onCreate

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.translate_fling_animation_activity);

    mViewTobeFlung = (ImageView) findViewById(R.id.iv_translate_fling);
    mTvFlingDistance = (TextView) findViewById(R.id.tv_fling_distance);
    mMainLayout = (RelativeLayout) findViewById(R.id.main_layout);

    final GestureDetector gestureDetector = new GestureDetector(this, mGestureListener);

    mViewTobeFlung.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    });


    mMainLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            maxTranslationX = mMainLayout.getWidth() - mViewTobeFlung.getWidth();
            maxTranslationY = mMainLayout.getHeight() - mViewTobeFlung.getHeight();
            //As only wanted the first call back, so now remove the listener
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
                mMainLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            else
                mMainLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });
}
 
开发者ID:richakhanna,项目名称:physicsbasedanimation,代码行数:33,代码来源:TranslateFlingAnimationActivity.java

示例14: PhotoViewAttacher

import android.widget.ImageView; //导入方法依赖的package包/类
public PhotoViewAttacher(ImageView imageView, boolean zoomable) {
    mImageView = new WeakReference<>(imageView);

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer)
        observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(
            imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getImageView());
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2,
                                       float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
    mBaseRotation = 0.0f;

    // Finally, update the UI so that we're zoomable
    setZoomable(zoomable);
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:57,代码来源:PhotoViewAttacher.java

示例15: addSelector

import android.widget.ImageView; //导入方法依赖的package包/类
public Selector addSelector(Drawable drawable, ColorListener colorListener) {
    if(drawable == null || colorListener == null) return null;

    final ImageView selectorImage = new ImageView(getContext());
    selectorImage.setImageDrawable(drawable);

    final Selector selector = new Selector(selectorImage, colorListener);
    LayoutParams thumbParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    thumbParams.gravity = Gravity.CENTER;

    selectorImage.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            switch (motionEvent.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    swapAlpha(selector);
                    mainSelector = selector;

                    Matrix invertMatrix = new Matrix();
                    palette.getImageMatrix().invert(invertMatrix);

                    float[] mappedPoints = new float[]{motionEvent.getX(), motionEvent.getY()};
                    invertMatrix.mapPoints(mappedPoints);

                    MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, motionEvent.getX(), motionEvent.getY(), 0);
                    dispatchTouchEvent(event);
                    break;
            }
            return false;
        }
    });

    addView(selector.getSelector(), thumbParams);
    swapAlpha(selector);
    selector.setSelectorListener(selectorListener);
    selector.onMoveCenter();
    selectorList.add(selector);
    mainSelector = selector;
    return selector;
}
 
开发者ID:skydoves,项目名称:Multi-ColorPicker,代码行数:41,代码来源:MultiColorPickerView.java


注:本文中的android.widget.ImageView.setOnTouchListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。