本文整理汇总了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());
}
});
}
示例2: getScaleListener
import android.view.ScaleGestureDetector.OnScaleGestureListener; //导入依赖的package包/类
protected OnScaleGestureListener getScaleListener() {
return new ScaleListener();
}
示例3: getScaleListener
import android.view.ScaleGestureDetector.OnScaleGestureListener; //导入依赖的package包/类
protected OnScaleGestureListener getScaleListener() {
return new ScaleListener();
}
示例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;
}
}
});
}