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

ImageView 관련해서 질문드립니다 답변부탁드려요

0 추천

 

사진 편집하는 기능을 만들고 있습니다.

위에 어플처럼 평소에는 첫번째 사진처럼 보여주다가 특정한 편집기능을 선택했을때 두번째 처럼 보여주게 하고 싶은데 어떻게 해야할지 감이 안잡히네요 보여주는  View영역이 줄어든건 알겠는데 이미지가 그자리 그대로 위치한 상태로 View영역을 어떻게 줄이는지 방법을 전혀 모르겠네요... 혹시 알고있으시다면 조언이나 도움주시면 감사하겠습니다.

이석호 1 (600 포인트) 님이 2014년 11월 26일 질문

1개의 답변

0 추천
이미지 사이즈를 계산해서 줄어든 ImageView사이즈 만큼 이미지의 가운데 영역을 잘라서 보여 주면 될듯하네요
q1212 (26,020 포인트) 님이 2014년 11월 26일 답변
가운데 영역만 잘라서 보여주면 Drag했을때 나머지 영역이 안보이지 않나요??
드래그까지 가능하려면 보여줄때 Canvas로 이미지의 보여지는 위치를 조절하시면 됩니다.

public void drawBitmap (Bitmap bitmap, Rect src, Rect dst, Paint paint)

Added in API level 1
Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle. If the source rectangle is not null, it specifies the subset of the bitmap to draw.

Note: if the paint contains a maskfilter that generates a mask which extends beyond the bitmap's original width/height (e.g. BlurMaskFilter), then the bitmap will be drawn as if it were in a Shader with CLAMP mode. Thus the color outside of the original width/height will be the edge color replicated.

This function ignores the density associated with the bitmap. This is because the source and destination rectangle coordinate spaces are in their respective densities, so must already have the appropriate scaling factor applied.

Parameters
bitmap    The bitmap to be drawn
src    May be null. The subset of the bitmap to be drawn
dst    The rectangle that the bitmap will be scaled/translated to fit into
paint    May be null. The paint used to draw the bitmap

http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Rect, android.graphics.Paint)
...