我在main.xml中间设置
<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/LinearLayout01"   
        android:layout_width="fill_parent"   
        android:layout_height="fill_parent"  
        android:background="@drawable/background"
       >  
其中background是一张png格式的图片,但是显示却是白色,后来我又找了几张图,同样大小,同样格式,有的能显示,有的却是只显示白色。。求解。这是为什么?

解决方案 »

  1.   

    你发mail.xml整个文件上来看看
      

  2.   


    <?xml version="1.0" encoding="utf-8"?>  
    <RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/LinearLayout01"   
            android:layout_width="fill_parent"   
            android:layout_height="fill_parent"  
            android:background="@drawable/background3"
           >  
    <com.lb.dragtest.MyViewPager
            android:id="@+id/viewpager"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
             />   <RelativeLayout
            android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" 
             >
            <LinearLayout 
             android:layout_width="fill_parent"
        android:layout_height="wrap_content"     
        android:orientation="horizontal" 
        android:layout_alignParentBottom="true"
        android:id="@+id/viewGroup" 
        android:gravity="center_horizontal"       
        android:layout_marginBottom="120dp"
                >           
            </LinearLayout>
        </RelativeLayout>
    <RelativeLayout 
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_alignParentBottom="true"
        >
             <Button
                 android:id="@+id/packets"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentRight="true"
                 android:onClick="shoppingcart"
                 android:background="@drawable/shopping_cart_normal" 
                 />
    </RelativeLayout>
            
            
    </RelativeLayout>  
      

  3.   

    看com.lb.dragtest.MyViewPager这个是不是有默认背景
      

  4.   


    这个没有默认背景。那个并不是设置不了背景,而是,有的图片能,有的图片不能,而且这些图片是同样分辨率,同样格式。
    不能的都是以纯白色为背景表现出来的。不明白为什么。难道Android的背景设置的图片还需要别的什么条件的?
      

  5.   

    MyViewPager 楼主先把这个去掉看看什么效果,会不会出现你说的那个效果
      

  6.   

    这个愿原因是:你使用的图片的格式是Android背景所不支持的格式
      

  7.   

    如果楼主出现的是有的图片可以,有些图片不可以,请检查:1、图片格式必须为png和jpg,也就是文件名称扩展名必须为.png或者.jpg2、图片的分辨率宽度和高度都要控制在1000像素以内;3、用Photoshop打开不能显示的图片,看是否为RGB格式,如果是CYMK格式的图片是不能显示的;4、图片文件名称必须全部小写,不能有大写的文件名称。
      

  8.   

    android:background   应该改成 android:src 引用图片应该用这个吧