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.
Related
I have 4activity and I want to set an image for these activities, I set the android:background="#drawable/background"property but it scales the image but I want this image set as a title image(set the background image size). I don't want to use ImageView because I want other views locate on the background Image.
how can I do this?
Is there any specific reason why this is happening?
This is the image after the transition happens.
You haven't provided any code to help us diagnose your problem, but your terrifying image (that looks like Jim Carrey) may be related to the tileMode. Your image looks like it's exhibiting clamping.
Clamping is when the edge color is replicated if the bitmap for an ImageView is smaller in size than the ImageView. These are all the options, along with a suitable picture of Jim:
disabled - Do not tile the bitmap. This is the default value.
clamp - Replicates the edge color.
repeat - Repeats the bitmap in both direction.
mirror - Repeats the shader's image horizontally and vertically, alternating mirror images so that adjacent images always seam.
Since it looks like your Bitmap is smaller than your ImageView and I don't think you actually want to use any tile mode (just use the default of disabled), I'd recommend either:
A) Use ImageView's setScaleType() so that the Bitmap resizes to fill the ImageView, using the centerCrop value (though check this blog for more examples), or...
B) Make your Bitmap larger
(I'd recommend A)
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.
I guess this question could be applied to both iphone and and android.
When I want to show smaller image,
I can set imageView to smaller size and let iphone handle the resizing to fit in the view.
Or
I can actually resize the image itself.(using opengl call, or such as wrapper call createScaledBitmap in android)
I find option 1 is faster.
I always wondered why?
I also wondered the memory consumed by the image is governed by the size of imageView or image?
This is good question, I think when we resize the imageView to smaller that And image(UIImage) is greater that time memory consumption is more because of that image (UIImage) size is more respect to display in imageView. I think second option would be good to save memory .
Image resizing need extra CPU cycles.So Its better to manually resize the image.
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.