现在我做的一个程序基本完成了但是在很多不同的机器的分辨率下面。有的布局却非常不好(主要是控件的大小和位子)。我现在是不是要做2套或者3套布局。还是在界面进入的时候直接调整控件大小和位置啊。有什么方法比较好用的,小弟希望各位指点。。

解决方案 »

  1.   

    这种问题肯定是有的,尤其是在真机上,我用G7 480*800和华为的320*480测试。<LinearLayout android:id="@+id/LinearLayout01"
    android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_height="fill_parent"
    android:background="@drawable/dicetwo" android:gravity="bottom">
    <Button android:id="@+id/Button_welcome01" android:text="PLAY"
    android:layout_height="65dip" android:textSize="25sp"
    android:layout_width="250dip"></Button>
    <Button android:text="MENU" android:id="@+id/Button_welcome02"
    android:textSize="25sp" android:layout_height="65dip"
    android:layout_marginTop="20dip" android:layout_width="250dip"></Button>
    <Button android:text="OPTIONS" android:id="@+id/Button_welcome03"
    android:layout_height="65dip" android:layout_marginBottom="20dip"
    android:layout_marginTop="20dip" android:layout_width="250dip"
    android:textSize="25sp"></Button>
    <Button android:id="@+id/Button_welcome04" android:text="HELP"
    android:layout_height="65dip" android:layout_width="250dip"
    android:layout_marginBottom="20dip" android:textSize="25sp"></Button>

    </LinearLayout>就这布局上面的按钮在g7上面的效果一般般大,可是到了C8600上面都快占满屏幕了
    恩。这怎么办啊
      

  2.   

    苹果系统好还是google的安卓好?
      

  3.   

    Android手机屏幕大小不一,有480×320, 640×360, 800×480.怎样才能让App自动适应不同的屏幕呢?
    其实很简单,只需要在res目录下创建不同的layout文件夹,比如layout-640×360,layout-800×480,所有的layout文件在编译之后都会写入R.java里,而系统会根据屏幕的大小自己选择合适的layout进行使用。这个我试了怎么不行哇。一建就出错。。哎。悲剧了
      

  4.   

    用<RelativeLayout>布局,或用<TablableLayout>布局
      

  5.   

    这个我也不知道有什么好方法,每次我都是获取屏幕的大小,然后通过屏幕大小设置不同layout,不知道这样方法可取不,下面是设置的代码:
                     if (height <= 427) {   //240*320 屏幕高度一般为 427
    setContentView(R.layout.mainsmall);
    } else if (height > 427 && height <= 480) {   //320*480 屏幕高度一般为 480
    setContentView(R.layout.main1);
    } else {
    setContentView(R.layout.main1big);
    }