티스토리 뷰

반응형

Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.

Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.

 

아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.

How can I get zoom functionality for images?

이미지에 대해 확대/축소 기능 구현하기

 문제 내용 

Is there a common way to show a big image and enable the user to zoom in and out and pan the image?

큰 이미지를 보여주고 사용자가 이미지를 확대/축소 및 이동할 수 있는 일반적인 방법이 있습니까?

 

Until now I found two ways:

지금까지 저는 두 가지 방법을 찾았습니다.

 

  1. overwriting ImageView, that seems a little bit too much for such a common problem.
  2. using a webview but with less control over the overall layout etc.
1. ImageView를 덮어쓰는 것은 그러한 일반적인 문제에 조금 무리가 있는 것 같습니다.
2. 웹 뷰를 사용하지만 전체 레이아웃 등에 대한 제어력이 떨어집니다.

 

 

 

 높은 점수를 받은 Solution 

UPDATE

갱신함

 

I've just given TouchImageView a new update. It now includes Double Tap Zoom and Fling in addition to Panning and Pinch Zoom. The code below is very dated. You can check out the github project to get the latest code.

방금 TouchImageView에 새로운 업데이트를 제공했습니다. 이제 패닝 및 핀치 줌 외에 더블 탭 줌 및 플링이 포함됩니다. 아래 코드는 매우 오래되었습니다. 당신은 최신 코드를 얻기 위해 github 프로젝트를 확인할 수 있습니다.

 

USAGE

사용법

 

Place TouchImageView.java in your project. It can then be used the same as ImageView. Example:

프로젝트에 TouchImageView.java를 배치합니다. 그러면 다음과 같이 사용할 수 있습니다. 이미지 보기. 예:
TouchImageView img = (TouchImageView) findViewById(R.id.img);

 

If you are using TouchImageView in xml, then you must provide the full package name, because it is a custom view. Example:

xml에서 TouchImageView를 사용하는 경우 전체 패키지를 제공해야 합니다. 커스텀 뷰이기 때문에 이름을 지정합니다. 예:
<com.example.touch.TouchImageView
    android:id="@+id/img”
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

 

Note: I've removed my prior answer, which included some very old code and now link straight to the most updated code on github.

참고: 매우 오래된 코드가 포함된 이전 답변을 제거했으며 이제 github에서 가장 업데이트된 코드로 바로 연결됩니다.

 

ViewPager

뷰페이저

 

If you are interested in putting TouchImageView in a ViewPager, refer to this answer.

ViewPager에 TouchImageView를 넣는 데 관심이 있는 경우 이 답변을 참조하십시오.

 

 

 

 가장 최근 달린 Solution 

I just integrated Robert Foss's TouchImageView: it worked perfectly out of the box! Thanks!

방금 로버트 포스의 터치 이미지 뷰를 통합했습니다. 개봉 즉시 완벽하게 작동했습니다! 감사합니다!

 

I just modified a bit the code so I could be able to instantiate it from my layout.xml.

나는 layout.xml에서 인스턴스화할 수 있도록 코드를 약간 수정했다.

 

Just add two constructors

생성자 두 개만 추가하십시오.
public TouchImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    init(context);
}

public TouchImageView(Context context) {
    super(context);
    init(context);
}

 

and transform the old constructor into an init method:

그리고 이전 생성자를 init 메서드로 변환합니다.
private void init(Context context){
    //...old code ofconstructor of Robert Moss's code
}

 

 

출처 : https://stackoverflow.com/questions/2537238/how-can-i-get-zoom-functionality-for-images

반응형
댓글
공지사항
최근에 올라온 글