Android Image Dialog/Popup

android custom popup dialog example
android dialog with edittext
android full screen dialog
android input dialog
android alertdialog custom view
types of dialog in android
android popup window
custom exit dialog android

Is it possible to have just an image popup/come-up in an Android application? It's similar to an overriding the normal view of an AlertDialog so that it contains just an image and nothing else.

SOLUTION: I was able to find an answer thanks to @blessenm's help. Masking an activity as a dialog seems to be the ideal way. The following is the code that I have used. This dialog styled activity can be invoked as needed by the application the same way a new activity would be started

ImageDialog.java

public class ImageDialog extends Activity {

    private ImageView mDialog;


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



        mDialog = (ImageView)findViewById(R.id.your_image);
        mDialog.setClickable(true);


        //finish the activity (dismiss the image dialog) if the user clicks 
        //anywhere on the image
        mDialog.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
        });

    }
}

your_dialog_layout.xml

<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/image_dialog_root" 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:gravity = "center">

    <ImageView
        android:id="@+id/your_image"  
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src = "@drawable/your_image_drawable"/>

</FrameLayout>

It is crucial that you set the following style for the activity to accomplish this:

styles.xml

  <style name="myDialogTheme" parent="@android:style/Theme.Dialog">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFrame">@null</item>
    <item name="android:background">@android:color/transparent</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>
    <item name="android:windowContentOverlay">@null</item>
   </style>

The final step is to declare this style for the activity in the manifest as follows:

 <activity android:name=".ImageDialog" android:theme="@style/myDialogTheme" />

If you just want to use a normal dialog something like this should work

Dialog settingsDialog = new Dialog(this);
settingsDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
settingsDialog.setContentView(getLayoutInflater().inflate(R.layout.image_layout
        , null));
settingsDialog.show();

image_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:orientation="vertical">
    <ImageView android:layout_width="wrap_content" 
        android:layout_height="wrap_content" android:src="YOUR IMAGE"/>
    <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:text="OK" android:onClick="dismissListener"/>
</LinearLayout>

Create Popup Custom Dialog With Image and Button Android Tutorials, This time I give a different tutorial, that is how we make an interesting dialog and according to Duration: 3:20 Posted: Oct 5, 2017 Android have two types of popup.One is Popup Window and another one is Popup Dialog. You will get both type of popup in this tutorial. Summary steps to develop an Android application is a below: 1) Create New Project in Android Studio. 2) Create Popup Window with button like camera, sound, gallery etc. 3) Create Popup Dialog with Message.

No xml:

public void showImage() {
    Dialog builder = new Dialog(this);
    builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
    builder.getWindow().setBackgroundDrawable(
        new ColorDrawable(android.graphics.Color.TRANSPARENT));
    builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            //nothing;
        }
    });

    ImageView imageView = new ImageView(this);
    imageView.setImageURI(imageUri);
    builder.addContentView(imageView, new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, 
            ViewGroup.LayoutParams.MATCH_PARENT));
    builder.show();
}

Dialogs, Overview · Manually flash an image · Recover a device · Connecting to Pop-up messages overview Dialogs · Menus Images & graphics. showDialog() method will create our custom dialog and will pop up it to the user. Read the below two lines of code. dialog.setCancelable(false); dialog.setContentView(R.layout.dialog_layout); First line will disable the cancelable property of dialog. It means that when user taps on the outside of the dialog to cancel it, it will not be canceled.

Try the following: It has image zoom_in/zoom_out as well.

Step 1: Add compile 'com.github.chrisbanes.photoview:library:1.2.4' to your build.gradle Step 2: Add the following xml


custom_fullimage_dialoge.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout_root" android:orientation="horizontal"
              android:layout_width="fill_parent" android:layout_height="fill_parent"
              android:padding="10dp">
    <ImageView android:id="@+id/fullimage" android:layout_width="fill_parent"
               android:layout_height="fill_parent">
    </ImageView>

    <TextView android:id="@+id/custom_fullimage_placename"
              android:layout_width="wrap_content" android:layout_height="fill_parent"
              android:textColor="#FFF">
    </TextView>
</LinearLayout>

Step 3:

private void loadPhoto(ImageView imageView, int width, int height) {

    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    //dialog.setContentView(R.layout.custom_fullimage_dialog);
    LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.custom_fullimage_dialog,
            (ViewGroup) findViewById(R.id.layout_root));
    ImageView image = (ImageView) layout.findViewById(R.id.fullimage);
    image.setImageDrawable(imageView.getDrawable());
    image.getLayoutParams().height = height;
    image.getLayoutParams().width = width;
    mAttacher = new PhotoViewAttacher(image);
    image.requestLayout();
    dialog.setContentView(layout);
    dialog.show();

}

Step 4:

user_Image.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Display display = getWindowManager().getDefaultDisplay();
        int width = display.getWidth();
        int height = display.getHeight();
        loadPhoto(user_Image,width,height);
    }
});

How to show the full size image in popup on clicking the image in , How do you show the full size image in pop up when clicking the picture on android? At the moment I am working on a file browser. Everything works fine with one exception: If the user clicks on an image (jpg, png, bmp, ..), I want the image to be displayed in a dialog or in a popup which has the same size as the image – so that there are no borders at all.

There is a couple ways you can do this. But, if you're looking to have your image appear to be floating above your existing activity, you may want to use an activity with android:theme="@style/Theme.Transparent" defined in the manifest. Then, design your layout to just have a single ImageView positioned in the center of the screen. The user will have to push the back button to get out of this, but it sounds like that's what you want.

If you want it to look like an actual dialog, you can always use a dialog styled activity as well using Theme.Dialog. OR, you could just use a dialog and customize it.

How to create a popup window (PopupWindow) in Android, on the other hand is able to do even more complex things . Create Popup Custom Dialog With Image and Button Android Tutorials Captain Code. How to Create a Custom Pop Up with Great UI in Android Studio - Duration:

The more flexible and recommended way is use DialogFragment. If you want to support versions before 3.0 you can use compatibility library

Android AlertDialog Example, Figure : AlertDialog with Image using ImageView. Alert Dialogs are used to display pop up windows over an Android Activity, they usually have  Now, lets create a function that when called, will display the pop up message box. To create a pop up, we use an AlertDialogBuilder. The builder allows us to set a number of parameters. After they have been set, we use the builder to build the dialog so we can then display it.

What is the difference between Dialog and AlertDialog?, android custom dialog with image and title.custom popup dialog with close ok two buttons tutorial with example android studio. Android Image Popup . Show image as a popup on a click event or any event. Simply set the image as drawable and thats it!!!. And also you can set width, height & background color as you want. Preview. Usage Step 1. Add the JitPack repository to your build file: allprojects { repositories { maven { url "https://jitpack.io" } } } Step 2.

AlertDialog with image using ImageView Example, Below is the code that will show the full size image in a dialog box popup without of image } else if(r.id.img_view==a) { uri = uri.parse("android.resource://" +  1. Create Android Popup Dialog With Input UI Controls Steps. Design and create the popup dialog ui layout xml file in app / res / layout folder. The layout xml file is popup_input_dialog.xml in this example. Use LayoutInflater to inflate above layout xml file to get the popup dialog view object.

Android custom dialog with image and title, close and two buttons, At the moment I am working on a file browser. Everything works fine with one exception: If the user clicks on an image (jpg, png, bmp, ..), I want the image to be​  A dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout. DatePickerDialog or TimePickerDialog A dialog with a pre-defined UI that allows the user to select a date or time. Caution: Android includes another dialog class called ProgressDialog that shows a dialog with a progress bar. This widget is

Comments
  • why using a Dialog styled activity and not a dialog itself to do the above functionality. Any specific reason for it, or just a design choice?
  • @Avijeet that's a valid question, the goal was to show a floating image - this was a few years ago though, when view customization wasn't as prevalent. So, it made sense to have an activity styled as a Dialog. In hindsight, I could have used a PopupWindow or rolled my own custom view
  • Thanks for the response - this does work but only partially. The dialog would still consist of the gray background and white stroke ala the style of an Android AlertDialog. My intention is to have an image replace the conventional alert dialog.
  • To remove all default styles, you should add your own style and overide the default values. This might help. anddev.org/…
  • Thank you! That was very helpful.
  • @Abhijit You dont have to create a custom style, there is already one without title or background,you can use DialogFragment.STYLE_NO_FRAME.
  • @Abhijit Well it's available backwards with the support library, if you are not using fragments then you can get the same style from the normal Dialog Class.
  • I used this but I can't see anything?
  • @ShylendraMadda it might not work if the image is huge
  • Thank you so much ! :)
  • add this line Dialog dialog = new Dialog(context, android.R.style.Theme_Light) can show the dialog in full screen, refer to stackoverflow.com/questions/10173544/…
  • Thanks a lot! My idea is to have an image replace the AlertDialog but disappear as the user taps/clicks on it. So, in essence the entire image space is working as an "OK" button. I will try to work with your first suggestion and get back to you. Also, when you say customize a dialog, do you mean that I subclass a dialog and override the methods?
  • Could you be possibly be a little more elaborate?
  • Add your example here for better explaination