我是android的新手。点击图像时,像whatsapp图像一样,将图像视图弹出到全屏(启用捏合缩放)的最简单方法是什么?我正在通过Glide在回收器视图中加载图像。感谢您的时间和答复。
小智 12
I used PhotoView (https://github.com/chrisbanes/PhotoView) and Glide (https://github.com/bumptech/glide).
I created full screen activity first and put PhotoView in layout.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
tools:context=".PhotoviewerActivity">
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/fullscreen_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
Then, I pass image URL that I want to show to the full screen activity and load image with Glide like below.
val imageUrl = intent.getStringExtra(IMAGE_URL)
Glide.with(applicationContext).load(imageUrl).into(fullscreen_content)
Run Code Online (Sandbox Code Playgroud)
You can remove all not needed code from full screen layout and also disable from full screen activity code. These codes are written in Kotlin.
有一个名为StfalconImageViewer的库。它支持开箱即用的过渡动画,用于图像的打开和关闭,捏合缩放和滑动消除手势。使用Glide可以像这样完成:
new StfalconImageViewer.Builder<>(context, images, new ImageLoader<String>() {
@Override
public void loadImage(ImageView imageView, String imageUrl) {
Glide.with(context).load(imageUrl).into(imageView)
}
}).show();
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!
归档时间: |
|
查看次数: |
3570 次 |
最近记录: |