Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android image full screen viewer

Tags:

android

I'm new to android.What is the easiest way to pop an imageview to full screen (with pinch zoom enabled),when it is tapped, just like whatsapp images? I'm loading my images in a recycler view via Glide. Thank you for your time and reply.

like image 415
Sobinscott Avatar asked Nov 25 '17 03:11

Sobinscott


People also ask

How do I view pictures full screen?

Press the keys Option–Command–F to view image in Full Screen.

How do you show the full size image in pop up when clicking the picture on android?

How to show the full size image in popup on clicking the image in android. Below is the code that will show the full size image in a dialog box popup without defining layout xml file . int a=v. getId(); intiger "a" will have the value equal to profile_pic if we touched on profile_pic imageview else we will get pro id .

How do I view full screen images in Chrome?

The quickest way to get Chrome in full-screen mode in Windows is to press F11 on the keyboard. The other way is through the Chrome menu: In the upper-right corner of Chrome, select the menu (three-dot) icon. In the Zoom section, select the square icon on the right.


3 Answers

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>

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)

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.

like image 83
diehard98 Avatar answered Oct 23 '22 06:10

diehard98


There is a library called StfalconImageViewer. It supports transition animation for image opening and closing, pinch-to-zoom and swipe-to-dismiss gestures out of the box. Using Glide it'll be done like this:

new StfalconImageViewer.Builder<>(context, images, new ImageLoader<String>() {
            @Override
            public void loadImage(ImageView imageView, String imageUrl) {
                Glide.with(context).load(imageUrl).into(imageView)
            }
        }).show();

Hope this helps!

like image 41
Alexander Krol Avatar answered Oct 23 '22 07:10

Alexander Krol


You are able to use ImageView view with scale type is FIT_XY(see more about scale type of ImageView here)

To zoom an image you can use a third lib such as this one or write a class by yourself(see here)

like image 43
John Le Avatar answered Oct 23 '22 07:10

John Le