小弟我是无基础,无经验,无天赋的三无人员,现在在学android开发,我想问两个问题,好吗?
1.我往drawable里面放的三张图片怎么显示的只有两张,那张LOGO的图片咋显示不鸟
下面是layout下main.xml的代码截图:<?xml version="1.0" encoding="utf-8"?>
   <LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
  <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ver"
    android:layout_marginTop="15dip"
    android:layout_marginLeft="15dip">
  </ImageView>
 <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
   <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/logo"
    android:layout_centerInParent="true">
  </ImageView>

 <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/dev"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_marginRight="5dip"
    android:layout_marginBottom="35dip">
  </ImageView>
 </RelativeLayout>
</LinearLayout>
问题2:
当在模拟器运行上面的UI时,只有黑白两色,我在drawable里面放入了一张背景图,就寻思着显示背景色,所以在网上找资料,写了两个方法,但是我把这两个方法放在mainactivity里面的,运行出来控制台总提示androidhelper con't be resolved.下面是代码package com.yarin.Android.MySinaWeibo;import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    public static int ScreenOrient(Activity activity)
    {
        int orient = activity.getRequestedOrientation(); 
        if(orient != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && orient != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
      //宽>高为横屏,反正为竖屏 
        WindowManager windowManager = activity.getWindowManager(); 
        Display display = windowManager.getDefaultDisplay(); 
        int screenWidth = display.getWidth(); 
        int screenHeight = display.getHeight(); 
        orient = screenWidth < screenHeight ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
  }
       return orient;
 }
    public static void AutoBackground(Activity activity,View view,int Background_v, int Background_h)
    {
         int orient=ScreenOrient(activity);
         if (orient == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { //纵向 
         view.setBackgroundResource(Background_v);
         }else{ //横向
         view.setBackgroundResource(Background_h);
         } 
    }
 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        LinearLayout layout=(LinearLayout)findViewById(R.id.layout);
        AndroidHelper.AutoBackground(this,layout,R.drawable.background,R.drawable.background);
    }
}
请原谅小弟把两个问题放在一起分,实在是囊中羞涩啊,分少!!

解决方案 »

  1.   

    xml是对的。我拷贝你的xml,放三张图,都显示出来了。可能是你图片格式,或者别的什么问题。你换图片试试。
      

  2.   

    您定义的三张图片是Logo,dev和ver吗?,另外我想请问一下,我把那两个方法写在mainactivity里面合适么,最后,那个androidhelper为什么没有定义呢,是需要引用还是要自己重写??
      

  3.   

    如果你单纯的只是想改变界面的背景颜色,在linearlayout的属性里面加上android:background=""的属性就好了。属性值可以填颜色#000000为黑色#ffffff为白色,#00000000为透明,也可以填背景图片@drawable/xxx.png。
      

  4.   

    我图片格式是BMP的,android不支持这种图片格式吗??
      

  5.   

    1、可能你dev图片太大,把Logo图片遮挡住了。
    2、不是androidhelper应该是MainActivity 吧
      

  6.   

    您觉得把方法写进MAINActivity里面好么
      

  7.   


    对,Android不支持BMP格式的图片。
    你可以换成别的格式,比如:.png, .jpg
    优先推荐.png