public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Variables
ImageView imageView;
imageView = (ImageView) findViewById(R.id.imageView);
//Loading into ImageView
Glide.with(this)
.load("http://vrijeme.hr/bradar.gif")
.into(imageView);
}
I tried using Picasso too and then connecting it with PhotoView library but it didn't do anything, when I tried pinch to zoom it didn't zoom at all, here is part of that code:
ImageView imageView;
PhotoViewAttacher photoView;
imageView = (ImageView) findViewById(R.id.imageView);
photoView = new PhotoViewAttacher(imageView);
Picasso.with(this)
.load("link")
.resize(1080,80)
.into(imageView);
This library here called PhotoView
is quite popular.
https://github.com/chrisbanes/PhotoView
With 13,500+ stars, 30+ contributors backing it, so many people using it and how easy it is to integrate into a project, it almost feels like a standard.
It's also compatible with Glide
^.^
Installation (Official documentation by chrisbanes)
Add this in your root build.gradle
file (not your module build.gradle
file):
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
Then, add the library to your module build.gradle
dependencies {
implementation 'com.github.chrisbanes:PhotoView:latest.release.here'
}
At that time of writing, latest.release.here
is 2.1.4
.
Usage (Official documentation by chrisbanes)
There is a sample provided which shows how to use the library in a more advanced way, but for completeness, here is all that is required to get PhotoView working:
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/photo_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
photoView.setImageResource(R.drawable.image);
That's it!
Usage with Glide
Nothing changes!!
PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
Glide.with(this).load(imageUrl).into(photoView);