开发者

How to avoid image stretching in imageview

I have a image with 320x480 and i am running the application in device with 320x480. I set Image as android:background then my image is stretched. but if i use android:src then i am getting white space behind the image as开发者_如何学JAVA if the image didnot cover the screen. How to set image in image view so that my image will neither be stretched and it will cover the whole screen.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff"
    >
    <ImageView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/about1"/>
</LinearLayout>


Take a look at the ImageView property adjustViewBounds.

Setting that to true has helped me in similar situations


Why don't you set the image as the background of the LinearLayout? If you do want to use the ImageView you should specify 'fill_parent' for the layout_height and layout_width.


You have to give height and width of image like you have image of 320*480 you have mention this size in xml while declaring the image and store the image in (drawable-mdpi)folder and then run it.


@Deepakkk

i think you have stored image in drawable in hdpi or ldpi which are for high desity or low density

for emulator of size 320 * 480 you should store your source image in mdpi

How to avoid image stretching in imageview

change height of image to fill parent

try this

 <manifest xmlns:android="http://schemas.android.com/apk/res/android">
        <supports-screens
            android:smallScreens="true"
            android:normalScreens="true"
            android:largeScreens="true"
            android:xlargeScreens="true"
            android:anyDensity="true" />
        ...
    </manifest>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜