昨天看了别人想,使图片显示自适应屏幕大小。我就试了获得屏幕的宽高,通过代码,相对的计算各个控件的  宽高。还没写出来,到这一步,运行。  发现 图片下方显示的文本,是执行的。 可是为什么会不显示呢?
我试着用宽度填充,  图片是随着屏幕尺寸不同而填充的,不过图片太小,容易画面失真。 为什么有人说不填充呢?   纵向填充,为什么上下,估计有个差不多一个编辑框大小的高度。  
想知道,原因,是我XML布局设计出错了吗?  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView
     android:id="@+id/TextView02"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:background="#FFFFFF"
     />
    <ImageView
     android:id="@+id/ImageView01"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     />
    <!--<ImageView
     android:id="@+id/ImageView01"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     >
         </ImageView>-->
<TextView  
android:id="@+id/TextView01"
android:layout_below="@id/ImageView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    />
</LinearLayout>package com.android.ImageView;import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;public class MainActivity extends Activity 
{
ImageView imageView;
TextView textView;
TextView m_TextView;
int image_alpha=10000;  //ImageView's alpha value
private final static String TAG= "MainActivity";

Handler mHandler = new Handler();
boolean isrun=false;
DisplayMetrics dm=new DisplayMetrics();

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        //取得窗口属性
        getWindowManager().getDefaultDisplay().getMetrics(dm);      
        int screen_Width=dm.widthPixels;
        int screen_Height=dm.heightPixels;       
        m_TextView=(TextView)findViewById(R.id.TextView02);
        m_TextView.setText("屏幕宽度:"+screen_Width+"\n"+"屏幕高度:"+screen_Height);
        
        isrun=true;       
        imageView = (ImageView)findViewById(R.id.ImageView01);
        textView = (TextView)findViewById(R.id.TextView01);
        
        //set image source
        imageView.setImageResource(R.drawable.iamge);
        imageView.setAlpha(image_alpha);
        
        new Thread(new Runnable()
        {
@Override
public void run()
{
while (isrun)
{
try
{
Thread.sleep(100);
updateAlpha();

catch (Exception e)
{
e.printStackTrace();
}
}

}
}).start();      
 
        //接收消息之后,更新Alpha的值
        mHandler =new Handler()
        {
         @Override
         public void handleMessage(Message msg)
         {
         super.handleMessage(msg);
         imageView.setAlpha(image_alpha);
         Log.i(TAG,"alpha");
         textView.setText("The value of Alpha"+   Integer.toString(image_alpha));
         Log.i(TAG,"setText");
         //更新
         imageView.invalidate();
         Log.i(TAG,"invalidate alpha");
         }
        };
        
    }
       
    public void updateAlpha()
    {
     if (image_alpha-7>=0)
     {
     image_alpha-=7;
     }
     else
     {
     image_alpha=0;
     isrun=false;
     }
     //发送需要更新ImageView的消息
     mHandler.sendMessage(mHandler.obtainMessage());
    }    }