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


Java OnScaleGestureListener类代码示例

本文整理汇总了Java中android.view.ScaleGestureDetector.OnScaleGestureListener的典型用法代码示例。如果您正苦于以下问题:Java OnScaleGestureListener类的具体用法?Java OnScaleGestureListener怎么用?Java OnScaleGestureListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ScaleHandlerFroyo

import android.view.ScaleGestureDetector.OnScaleGestureListener; //导入依赖的package包/类
public ScaleHandlerFroyo(Context c, ScaleListener listener) {
    mScaleListener = listener;
    mScaleDetector = new android.view.ScaleGestureDetector(c, new OnScaleGestureListener() {

        @Override
        public void onScaleEnd(ScaleGestureDetector detector) {
            mScaleListener.onScaleEnd(detector.getScaleFactor(), detector.getFocusX(), detector.getFocusY());
        }

        @Override
        public boolean onScaleBegin(ScaleGestureDetector detector) {
            return mScaleListener.onScaleBegin(detector.getScaleFactor(), detector.getFocusX(), detector.getFocusY());
        }

        @Override
        public boolean onScale(ScaleGestureDetector detector) {
            return mScaleListener.onScale(detector.getScaleFactor(), detector.getFocusX(), detector.getFocusY());
        }
    });
}
 
开发者ID:ncornette,项目名称:ZoomableView,代码行数:21,代码来源:ScaleHandler.java

示例2: getScaleListener

import android.view.ScaleGestureDetector.OnScaleGestureListener; //导入依赖的package包/类
protected OnScaleGestureListener getScaleListener() {
	return new ScaleListener();
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:4,代码来源:ImageViewTouch.java

示例3: getScaleListener

import android.view.ScaleGestureDetector.OnScaleGestureListener; //导入依赖的package包/类
protected OnScaleGestureListener getScaleListener() {
    return new ScaleListener();
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:4,代码来源:ImageViewTouch.java

示例4: init

import android.view.ScaleGestureDetector.OnScaleGestureListener; //导入依赖的package包/类
private void init()
{
    sharedPreferences = getSharedPreferences(getPackageName(), MODE_PRIVATE);
    
    mtv_reader = (MyTextView) findViewById(R.id.mtv_reader);
    
    scaled_density = getResources().getDisplayMetrics().scaledDensity;
    text_size_dp_default = mtv_reader.getTextSize() / scaled_density;
    
    mtv_reader.setTextSize(text_size_dp_default +
        sharedPreferences.getFloat("reader_text_size_dp_extra", 0.0f));
    
    scaleGestureDetector = new ScaleGestureDetector(this, new OnScaleGestureListener()
    {
        @Override
        public boolean onScale(ScaleGestureDetector p1)
        {
            return false;
        }

        @Override
        public boolean onScaleBegin(ScaleGestureDetector p1)
        {
            return true;
        }

        @Override
        public void onScaleEnd(ScaleGestureDetector p1)
        {
            final float SCALE_FACTOR = p1.getScaleFactor();
            if (SCALE_FACTOR >= 0.8f && SCALE_FACTOR <= 1.2f)
            {
                return;
            }

            final float OLD_TEXT_SIZE_DP = mtv_reader.getTextSize() / scaled_density;
            if (OLD_TEXT_SIZE_DP <= text_size_dp_default - 4.0f && SCALE_FACTOR <= 1.0f)
            {
                return;
            }
            if (OLD_TEXT_SIZE_DP >= text_size_dp_default + 4.0f && SCALE_FACTOR > 1.0f)
            {
                return;
            }
            
            final float NEW_TEXT_SIZE_DP = SCALE_FACTOR > 1.0f ? (OLD_TEXT_SIZE_DP + 4.0f)
                : (OLD_TEXT_SIZE_DP - 4.0f);
            
            //Unit: dp
            sharedPreferences.edit().putFloat("reader_text_size_dp_extra",
                NEW_TEXT_SIZE_DP - text_size_dp_default).commit();
            mtv_reader.setTextSize(NEW_TEXT_SIZE_DP);
        }
    });
    
    mtv_reader.setOnTouchListener(new OnTouchListener()
    {
        @Override
        public boolean onTouch(View p1, MotionEvent p2)
        {
            switch (p2.getPointerCount())
            {
                case 2:
                {
                    //Disallow HorizontalScrollView to intercept touch events.
                    p1.getParent().requestDisallowInterceptTouchEvent(true);
                    //Disallow ScrollView to intercept touch events.
                    p1.getParent().getParent().requestDisallowInterceptTouchEvent(true);
                    return scaleGestureDetector.onTouchEvent(p2);
                }
                default:
                    return false;
            }
        }
    });
}
 
开发者ID:by-syk,项目名称:OSBuild,代码行数:77,代码来源:ReaderActivity.java


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