Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: ImageView scales up source image

I can't seem to get my ImageView to display its source image in its original size. The ImageView looks like this:

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

The source image is 140 pixels wide, yet on the Nexus One's screen, which is 480 pixels wide it uses up half of the width. Using absolute values in px or dp for the width and height changes nothing. The image also looks very antialiased from the upscaling. Why is this happening and how can I prevent it?

like image 684
Steven Meliopoulos Avatar asked May 30 '10 11:05

Steven Meliopoulos


People also ask

How do I make my android picture fit the screen?

setMinimumWidth(width); imgView. setMinimumHeight(height); imgView. setMaxWidth(width); imgView. setMaxHeight(height);

How can I find the aspect ratio of an image in android?

float aspect_ratio = (float)originalWidth / (float)originalHeight ; Because this typecasting operation will return a float value.

What is adjust view bounds?

android:adjustViewBounds—If set to true, the attribute adjusts the bounds of the ImageView control to maintain the aspect ratio of the image displayed through it. android:resizeMode—The resizeMode attribute is used to make a control resizable so we can resize it horizontally, vertically, or around both axes.


1 Answers

Most likely, Android is scaling up the image, because you did not tell it you were supporting large screens. Add a suitable <supports-screens> element to your manifest and see if that helps.

like image 110
CommonsWare Avatar answered Oct 08 '22 06:10

CommonsWare