2013-06-14 4 views
0

나는 카메라 미리보기와 마지막으로 찍은 이미지의 ImageView를 보여주는 활동이 있습니다.손가락으로 ImageView의 높이를 조절하십시오.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

<ImageView 
     android:id="@+id/stitch_preview" 
     android:layout_width="fill_parent" 
     android:layout_height="128dp" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:scaleType="center" 
     android:visibility="gone"/> 

<SurfaceView 
     android:id="@+id/camera_preview" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_below="@+id/stitch_preview"/> 

지금 ImageView는 128dp 높이로 고정되어 있습니다. ImageView에서 손가락을 끌어서이보기를 크기를 조정할 수 없습니다.

나는 다양한 힌트를 찾고 있었지만, 내가 발견 한 모든 것은 숨겨진보기를 꺼내는 것과 관련이있다. 이미 가시적 인보기의 크기를 조정하는 예제를 찾을 수 없습니다.

Tutorial for doing a pull-down "view" in android? 당신의 이미지 뷰가 표시되는 것을 가정하여

How to resize a custom view programmatically?

답변

1

, 다음 단계는 도움이 될 수 있습니다 당신은 -

1) 핀치 - 줌 (멀티 터치를 사용하여의 LayoutParams를 사용하여 이미지 뷰의 크기를 조정하여 이미지 뷰 또는 실제로 당신 표준 바인딩에 따라 Imageview의 크기를 조정할 수 있습니다).

2) ... 코드

ImageView iv=(ImageView)findViewbyId(R.id.ImageView1) 

다음 사용하여 이미지 뷰의 캡처를 받아

iv.setDrawingCacheEnabled(true); 
       // Set the layout manually to after resizing or pinch zoom 
       iv.layout(0, 0, x, y); 
       // Set the quality to high 
       iv.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); 
       // Build the cache, get the bitmap and close the cache 
       iv.buildDrawingCache(true); 
       Bitmap bmBarChart = gv.toBitmap(); 

위의 코드는 당신에게 다시 크기의 비트 맵 이미지를 반환합니다.

3) 이제이 이미지를 저장하고 이미 전에 볼 수보기를 크기를 조정 한

귀하의 이미지 뷰로 설정하지만 난 당신

보다 약간 다른 요구 사항을 가지고 있었다
관련 문제