마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 Layout 및 ZoomView 관련해서 질문드립니다

0 추천

 

안녕하세요.. Android-Zoom-View API를 사용하고 있는데 문제점이 있어서 질문을 드립니다.

LinearLayout에 AddviEw를 통해 웹뷰를 올리고 ZoomView에 올렸는데 첫페이지 이후로 보이지는 않네요...

확대를 하면 아럐쪽으로 가긴 가는데 확대가 안된 상태에서는 도무지 방법이 보이지 않아서 질문 드립니다ㅠ

소스입니다.

Main

		LinearLayout ly = new LinearLayout(this);
		LayoutParams params = new LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT,
				android.widget.LinearLayout.LayoutParams.MATCH_PARENT);
		ly.setLayoutParams(params);
		ly.setOrientation(LinearLayout.VERTICAL);
		mainLinearLayout = ly;

		// sv.addView(ly);

		 //줌뷰 객체 생성후
		 zoomView = new ZoomView(this);
		 //줌컨텐츠를 줌뷰에 넣어준다
		
		 zoomView.addView(ly);
		 //줌뷰를 컨테이너에 붙여준다
		 FrameLayout main_container = (FrameLayout)
		 findViewById(R.id.createConsentnote_root);
		 main_container.addView(zoomView,0);

ZoomView (Maximum에 걸려서 계산하는쪽만 올려봅니다)

@Override
	protected void dispatchDraw(final Canvas canvas) {
		// do zoom
		zoom = lerp(bias(zoom, smoothZoom, 0.05f), smoothZoom, 0.2f);
		smoothZoomX = clamp(0.5f * getWidth() / smoothZoom, smoothZoomX, getWidth() - 0.5f * getWidth() / smoothZoom);
		smoothZoomY = clamp(0.5f * getHeightCustom() / smoothZoom, smoothZoomY,
				getHeightCustom() - 0.5f * getHeightCustom() / smoothZoom);

		zoomX = lerp(bias(zoomX, smoothZoomX, 0.1f), smoothZoomX, 0.35f);
		zoomY = lerp(bias(zoomY, smoothZoomY, 0.1f), smoothZoomY, 0.35f);

		if (zoom != smoothZoom && listener != null) {
			listener.onZooming(zoom, zoomX, zoomY);
		}

		final boolean animating = Math.abs(zoom - smoothZoom) > 0.0000001f || Math.abs(zoomX - smoothZoomX) > 0.0000001f
				|| Math.abs(zoomY - smoothZoomY) > 0.0000001f;

		// nothing to draw
		if (getChildCount() == 0) {
			return;
		}

		// prepare matrix
		m.setTranslate(0.5f * getWidth(), 0.5f * getHeightCustom());
		m.preScale(zoom, zoom);

		float dx2 = -zoomX;// = -clamp(0.5f * getWidth() / zoom, zoomX,
							// getWidth() - 0.5f * getWidth() / zoom);
		float dy2 = -zoomY;// = -clamp(0.5f * getHeightCustom() / zoom, zoomY,
							// getHeightCustom() - 0.5f * getHeightCustom() /
							// zoom);

		Log.d("2", "preTranslate 1 : " + dx2 + " , " + dy2);
		Log.d("2", "preTranslate 2 : " + zoomX + " , " + zoomY);
		Log.d("2", "preTranslate 2 : " + (0.5f * getWidth()) + " , " + (0.5f * getHeightCustom()));
		Log.d("2", "preTranslate 3 : " + (getWidth() - 0.5f * getWidth() / zoom) + " , "
				+ (getHeightCustom() - 0.5f * getHeightCustom() / zoom));

		m.preTranslate(dx2, dy2);

		// get view
		final View v = getChildAt(0);

		dx2 = v.getLeft();
		dy2 = v.getTop();
		Log.d("2", "preTranslate 2: " + dx2 + " , " + dy2);

		m.preTranslate(v.getLeft(), v.getTop());

		// get drawing cache if available
		if (animating && ch == null && isAnimationCacheEnabled()) {
			v.setDrawingCacheEnabled(true);
			ch = v.getDrawingCache();
		}

		// draw using cache while animating
		if (animating && isAnimationCacheEnabled() && ch != null) {
			p.setColor(0xffffffff);
			canvas.drawBitmap(ch, m, p);
		} else { // zoomed or cache unavailable
			ch = null;
			canvas.save();
			canvas.concat(m);
			v.draw(canvas);
			canvas.restore();
		}


		// redraw
		// if (animating) {
		getRootView().invalidate();
		invalidate();
		// }
	}

	private float clamp(final float min, final float value, final float max) {
		return Math.max(min, Math.min(value, max));
	}

	private float lerp(final float a, final float b, final float k) {
		return a + (b - a) * k;
	}

	private float bias(final float a, final float b, final float k) {
		return Math.abs(b - a) >= k ? a + k * Math.signum(b - a) : b;
	}

 

행인28 (480 포인트) 님이 2016년 6월 10일 질문

1개의 답변

0 추천
아마도 스크롤 안되는 라이브러리 인가 보네요.

다른거쓰세요

https://github.com/Frank-Zhu/PullZoomView
익명사용자 님이 2016년 6월 10일 답변
...