如何在Android中的多个文本视图上手动缩放和缩小?

时间:2015-08-21 05:27:18

标签: android android-activity zoom textview pinchzoom

如何在framelayout中手动拖放多个文本视图?
我添加了两个textview,我想同时在单个textview上拖放功能。

我在framelayout中添加了textviews。这是我的代码::

Powershell.exe -ExecutionPolicy Bypass -Command "test1.ps1 -Tag Value1 -CommitId Value2"

1 个答案:

答案 0 :(得分:2)

尝试触摸事件

public boolean onTouchEvent(MotionEvent event) {
    if (event.getPointerCount() == 2) {
        int action = event.getAction();
        int pure = action & MotionEvent.ACTION_MASK;
        if (pure == MotionEvent.ACTION_POINTER_DOWN) {
            mBaseDist = getDistanceevent(event);
            mBaseRatio = mRatio;
        } else {
            float delta = (getDistanceevent(event) - mBaseDist) / STEP;
            float multi = (float) Math.pow(2, delta);
            mRatio = Math.min(1024.0f, Math.max(0.1f, mBaseRatio * multi));
            mytv.setTextSize(mRatio + 13);
        }
    }
    return true;
}

int getDistanceevent(MotionEvent event) {
    int dx = (int) (event.getX(0) - event.getX(1));
    int dy = (int) (event.getY(0) - event.getY(1));
    return (int) (Math.sqrt(dx * dx + dy * dy));
}

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