Resize AlertDialog to fit image exactly
I have the following AlertDialog with an image inside it:
As you can see there is a small gap just above and just below the image. I'd like to remove that gap.
My layout xml looks like:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/alert_thumb_root" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/thumb" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>
Unless you create the whole dialog by your self, it's really difficult to control those kind of things. However, if you don't mind resizing the image, you could try something like:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/alert_thumb_root" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/thumb" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="fitXY"/> </LinearLayout>
How to make an alert dialog fill 90% of screen size?, getWindowVisibleDisplayFrame(displayRectangle); // inflate and adjust layout LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context. The blue highlight is all of the high level parts (Window, frames for the Dialog visual style, etc) and from the end of the blue down is where the components for the AlertDialog are (red = title, yellow = a scrollview stub, maybe for list AlertDialogs, green = Dialog content i.e. custom view, orange = buttons).
See this question and its answer on how to create a Dialog without any UI, or rather, where anything visible was put there by you.
This question/answer apparently does the same thing, and seems simpler. Haven't tried it, though.
The New And Improved Image Size Dialog Box In Photoshop CC, The Image Resizing Options. Below the Fit To option, we find three very important options - Width, Height and Resolution - that together make up the main image� How to Resize Image with Fotor's Image Resizer? 1. Open the Photo Resize and the image you want to edit. 2. Type the proportions you want in the "Width" and "Height" fields or enter a percentage to determine the size of the photo. 3. Check the "Keep Proportions" option if you want to maintain the proportions from the original image. 4
The best and easy way to achieve this programmatically is to
Photoshop's Image Size Command, Photoshop's Image Size dialog box is Command Central for resizing images. This means that each pixel in your image takes up exactly one pixel on your screen. You'll find them in the Fit To option directly below the current image size:. Then, go to the Home menu bar and click on the resize option. Now, resize window appears, where you have two options, one is percentage and second is pixels. To resize the image in percentage, select percentage button and type required width and height, then click OK button.
Resize Page dialog box, Resize Page dialog box Click the Resize tool image\Resize_Tool.gif . In Page View, click the The result is that a different amount of music will fit on a page. To make them all the same size, first, select all of the images by holding ctrl and clicking each image in turn. Head over to the “Format” tab under “Picture Tools.” Over in the “Size” group, enter the height and width you want for the images.
Resizing the canvas, If you want to resize by adjusting the image size, see Resizing images. What is the difference Image Canvas Size. The Canvas Size dialog box appears. Resize & crop your photos online. On PhotoResizer.com you can resize, shrink, grow and crop your photos, images and pictures online, for free. Open your image and crop and resize. You can crop to pre-defined formats for Facebook, Instagram or Twitter headers or make custom crops.
Specify the image on your computer or phone, enter the size you want in inches, millimeters or centimeters, click OK button at the bottom of the page, wait a few seconds and download the finished result. Other settings are already set by default.
- It works but like you said it does resize the image. I can't understand why Android just doesn't make it the same size as the image... what's the reason for making it bigger?
- I'm facing the same challenge. Have you perhaps found an answer?
- +1 Thank you ! Helped me with a similar issue, that android:scaleType="fitXY" worked, in combination with wrap_content when rendering a bitmap to a custom Dialog.