我使用一张240*320的图片放在布局里面做背景,但显示在真机(分辨率240*320)上时背景会失真,模糊不清的。有没有人遇到这种问题,怎么解决啊?
我的布局如下:<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<ImageView  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/welcome"
/>
</LinearLayout>

解决方案 »

  1.   

    <ImageView 
            android:layout_width="fill_parent"        android:layout_height="fill_parent"
            android:scaleType="fitXY"
    />
      

  2.   

    效果还是一样,还是失真。为什么真机直接打开图片的时候非常清晰,而使用 android:background="@drawable/welcome就不清楚呢
      

  3.   

    解决了,不使用背景,直接在ImageView上加载图片就不会失真。   ImageView image1 = (ImageView) findViewById(R.id.img);
       Resources r = getResources();   
       //以数据流的方式读取资源   
       InputStream is = r.openRawResource(R.drawable.welcome);   
       BitmapDrawable  bmpDraw = new BitmapDrawable(is);   
       Bitmap bmp = bmpDraw.getBitmap();  
       image1.setImageBitmap(bmp);