用相对布局也可以,直接在xml文件中写出来,不要用手拖,容易出问题,而且控件多的话最好不要用相对布局,它每个控件都是相关联的,牵一发而动全身在编译时容易出问题

解决方案 »

  1.   

    使用AbsoluteLayout布局,绝对坐标布局,例如:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout android:orientation="vertical"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
      xmlns:android="http://schemas.android.com/apk/res/android">
       <AbsoluteLayout 
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          >
          <ImageView 
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:layout_x="0dp"
              android:layout_y="0dp"
              android:background="@drawable/workbg"
              />
          <ImageView 
              android:layout_width="150px"
              android:layout_height="30px"
              android:layout_x="0dp"
              android:layout_y="5px"
              android:background="@drawable/logo"/>
          <TextView 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_x="260px"
              android:layout_y="0px"
              android:text="手机无线扫描枪"
              android:textSize="20sp"
              android:textColor="#ffffffff"
              />      <ImageButton
              android:layout_width="150px"
              android:layout_height="150px"
              android:layout_x="50px"
              android:layout_y="120px"
              android:background="@drawable/uploaddatabg" 
              android:onClick="onclickUpload"/>      <ImageButton
              android:layout_width="150px"
              android:layout_height="150px"
              android:layout_x="280px"
              android:layout_y="120px"
              android:background="@drawable/downloaddatabg" 
              android:onClick="onclickDownload"/>      <ImageButton
              android:layout_width="150px"
              android:layout_height="150px"
              android:layout_x="50px"
              android:layout_y="330px"
              android:background="@drawable/updownline" 
              android:onClick="onclickUpDown"/>      <ImageButton
              android:layout_width="150px"
              android:layout_height="150px"
              android:layout_x="280px"
              android:layout_y="330px"
              android:background="@drawable/updownlineorder" 
              android:onClick="onclickUpDownOrder"/>
          
          <ImageButton
              android:layout_width="150px"
              android:layout_height="150px"
              android:layout_x="50px"
              android:layout_y="540px"
              android:background="@drawable/offlinesearch" 
              android:onClick="onclickOfflineSearch"/>      <ImageButton
              android:layout_width="150px"
              android:layout_height="150px"
              android:layout_x="280px"
              android:layout_y="540px"
              android:background="@drawable/backbg" 
              android:onClick="onclickBack"/>
      </AbsoluteLayout>
       
    </LinearLayout>
    效果图: