아하
생활

생활꿀팁

행운의매164
행운의매164

SurfaceView Zoom 하는 방법이 따로 있나요?

public static float _X, _Y, mScaleX = 1.0f, mScaleY = 1.0f, mMaxZoomLimit = 2.0f, mMinZoomLimit = 1.0f; public static int offset = 0, duration = 100; @Override public boolean onTouchEvent(MotionEvent event) { if(CmdStatus.GetFuncState(CmdStatus.FuncZOOM) != 0) { touchToZoom(event, event.getX(), event.getY()); } return true; } void touchToZoom(MotionEvent e, float x, float y) { int _ZoomControll = e.getAction(); switch(_ZoomControll) { case MotionEvent.ACTION_DOWN: mZoomIn(mGLSurfaceView, x, y); break; } } void mZoomIn(View v, float x, float y) { if (mScaleX < mMaxZoomLimit && mScaleY < mMaxZoomLimit) { Animation animation = new ScaleAnimation(mScaleX, (mScaleX + 1.0f), mScaleY, (mScaleY + 1.0f), x, y); mScaleX += 1.0f; mScaleY += 1.0f; animation.setInterpolator(new DecelerateInterpolator()); animation.setDuration(duration); animation.setStartOffset(offset); animation.setFillAfter(true); v.startAnimation(animation); } }

현재 SurfaceView 안에서 이런식으로 Zoom을 작동시키고 있습니다. 물론 제대로 작동 하지 않구요. 무언가 SurfaceView는 다른 Zoom 방법이 있는건가요? 참고할만한 사이트를 알려주셨으면 합니다.

하나 더 질문드리자면, 이 Zoom 그냥 화면을 늘리는 것인데 이걸 화면이 늘어지는 게 아닌 별도의 레이아웃 창에 Zoom 된 화면을 띄우는 방법이 있나요?

    55글자 더 채워주세요.
    1개의 답변이 있어요!
    • 화사한레아163
      화사한레아163

      SurfaceView에서는 onDraw() 함수를 오버라이드해서 줌된 화면을 계속해서 다시 드려줘야 합니다.

      TouchEvent를 통해서 SurfaceView 내부의 width(x)와 height(y) 변수의 값을 조정하고, 이 값을 기준으로 onDraw() 함수 내에서 계속해서 이 값을 기준으로 뷰를 그려줘야 합니다.

      참고 자료 함께 첨부해드리겠습니다.

      https://android-developers.googleblog.com/2010/06/making-sense-of-multitouch.html