How to get images one size - android

I have a quiz app created however the images are different sizes. Would it make sense to use a gridview for one image or is there a way to make sure imageview is set to the same size for different images?

You can limit the ImageView size instead of use wrap_content just write a static number for example
300dp
the image will fill the ImageView no matter how big the picture is.

Related

android difference between imageview and linear layout for showing image

i have some image (either resource image or bitmap image)
what is the major difference between showing them in ImageView or set them as background in LinearLayout.
any difference in Quality or Memory usage ?
what is the major difference between showing them in ImageView or set
them as background in LinearLayout.
When you set a background to a layout.It may re-size and change the shape of the image.So it may change your expected output view.
ImageView is specially designed for setting images and it has extra features like android:scaleType, you can set the exact image and use function like crop.
any difference in Quality or Memory usage
Image view is a view and it will reduce the computation of loading the layout each time while using a layout for this porpose.

how to dynamically load the images with different sizes in view pager android

I am implementing user wall like facebook but i want to display image
as with original size. And I am using view pager to display images.
So how to display images according to screen size?
Thanks in advance..
You need to use one of the scale types provided with ImageView class. How do you handle if the image is way larger than the screen, say taken from a DSLR at 3000x3000 resolution? What happens if the image is too small?
Have a look at the documentation for ImageView.ScaleType:

Displaying images from the web?

How to display an image using a URL of a known jpg, png ..etc. File ?
I want an image , and I want it to be loaded from the internet from a particular website.
With that done,
I would like to make that image of an appropriate size...
Say I put the width as the same as screen_width (size)....What about the height ? I don't want to spoil the ratio of height/width of the original image...So is the height automatically set to account for the ratio ? or do I have to put in some value myself ...?
Plus, I want it to be zoomable.
To load images from website, you need to get the path from website server where the photo is stored. For image displaying put height as wrap_content mode so that the space will occupy as much as needed to display.
For this purpose you can use a Lazy Adapter. Here you can find a good example of it: https://stackoverflow.com/a/3068012/2436683. Maybe you can use it as a starting point.

Crop and resize an image to use on a list

I need to crop and center an image to make a thumbnail for a list, but I want the size of the thumbnail to be proportional to the screen size, so that when the list is shown on a tablet or on a phone the image can be perceptible.
Any idea how can I do this?
You can use an ImageView to display the thumbnail.
Set the size of the ImageView in the layout XML, where you can set a different size for each screen size, by following this guide: http://developer.android.com/training/basics/supporting-devices/screens.html
Make sure the scale type of the ImageView is set according to your need by setting the correct android:scaleType property to your ImageView. The available scale types can be found here: http://developer.android.com/reference/android/widget/ImageView.ScaleType.html
That should do the trick.

Creating photo miniature in a List View row

I want to create a list with some text and a photo miniature in each row.
So I created a row layout with a TextView and a ImageView, my question is how do I make the ImageView just a little square and then make an image adapt to the size of the ImageView?
<ImageView .... android:scaleType="centerInside" />
Set full screen image as an image resource of this image view. It will be downscaled automatically.
Additionally you can limit width and height setting android:maxWidth and android:maxHeight attributes to prevent minature to be too large.
my recommendation is you do not scale the image to fit the view as this is an expensive operation and will slow down your app it is preferable to prescale the item to the size you want.
Take a look at this Strange out of memory issue while loading an image to a Bitmap object. It's a correct way to get miniature with minimum memory consumption.

Categories

Resources