LoginSignup
1
2

More than 5 years have passed since last update.

PhotoView

Posted at

PhotoView

ImageViewを簡単にズームできるようにするライブラリらしい...
https://github.com/chrisbanes/PhotoView

準備

githubの説明通り通り、build.gradleに記述

build.gradle

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

Moduleのbuild.gradleにも記述(そのままだとエラー吐くので修正)

build.gradle
dependencies {
    compile 'com.github.chrisbanes.photoview:library:+'
}

レイアウト

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <uk.co.senab.photoview.PhotoView
        android:id="@+id/photo_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

Activity

MainActivity
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        PhotoView photoView = view.findViewById(R.id.photo_view);
        photoView.setImageResource(R.drawable.image);
    }
}

感想

  • PhotoViewはImageViewを継承していて、ImageViewと同じ感覚で使用できるので使いやすい
  • ライブラリ自体のコード量もそこまで多くないので構造を理解すれば自分でも似たようなものを作れそう
  • 技術としては古いのに参考資料が少ないのはなんでだろう...
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2