저는 MikeOrtiz TouchImageView
을 사용하고 있습니다. GitHub에서. 여기 만 여기에 가로 방향의 화면으로 폭에 맞게 설정하려고 해요 링크 TouchImageView안드로이드에서 가로 방향 (TouchImageView 사용)의 화면 너비를 맞추는 방법
내가하고 싶은 것을 보여줄 수있는 이미지입니다.
은 내가 여기에 몇 가지 코드 대신에 내가
풍경 지금 받고있어 어떤이의이
- 를 원한다.
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); viewWidth = MeasureSpec.getSize(widthMeasureSpec); viewHeight = MeasureSpec.getSize(heightMeasureSpec); // // Rescales image on rotation // if (oldMeasuredHeight == viewWidth && oldMeasuredHeight == viewHeight || viewWidth == 0 || viewHeight == 0) return; oldMeasuredHeight = viewHeight; oldMeasuredWidth = viewWidth; if (saveScale == 1) { // Fit to screen. float scale; Drawable drawable = getDrawable(); if (drawable == null || drawable.getIntrinsicWidth() == 0 || drawable.getIntrinsicHeight() == 0) return; int bmWidth = drawable.getIntrinsicWidth(); int bmHeight = drawable.getIntrinsicHeight(); Log.d("bmSize", "bmWidth: " + bmWidth + " bmHeight : " + bmHeight); float scaleX = (float) viewWidth/(float) bmWidth; float scaleY = (float) viewHeight/(float) bmHeight; scale = Math.min(scaleX, scaleY); matrix.setScale(scale , scale); // Center the image float redundantYSpace = (float) viewHeight - (scale * (float) bmHeight); float redundantXSpace = (float) viewWidth - (scale * (float) bmWidth); redundantYSpace /= (float) 2; redundantXSpace /= (float) 2; matrix.postTranslate(redundantXSpace, redundantYSpace); origWidth = viewWidth - 2 * redundantXSpace; origHeight = viewHeight - 2 * redundantYSpace; setImageMatrix(matrix); } fixTrans(); }
감사합니다
기본적으로 내가 그것을 현명 화면 너비에 맞게해야 있도록 방향 변경에 내 이미지 뷰의 확대를 변경해야합니다. 그러나 모르겠다 :( –