现在我做的一个程序基本完成了但是在很多不同的机器的分辨率下面。有的布局却非常不好(主要是控件的大小和位子)。我现在是不是要做2套或者3套布局。还是在界面进入的时候直接调整控件大小和位置啊。有什么方法比较好用的,小弟希望各位指点。。
解决方案 »
- android项目开发,红色代码提示错误,如何修改,求大神帮忙!
- anroid4.0 设置菜单settings如何删除条目屏幕锁定
- android的autoCompleteTextVeiw控件问题
- ndk C调用java中的方法
- 用什么方法能够结束一个应用程序?
- android 录音问题 !!急!!!!!!!!
- 大家给我提提建议吧!
- android 小白问题
- android 导入原完成的工程出错,求助~
- LayoutInflater.inflate(R.id.taskview,null);老是报错!求解!
- android布局问题
- 请问如何获取imageButton的背景图片的资源ID并且打印出来?
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上面都快占满屏幕了
恩。这怎么办啊
其实很简单,只需要在res目录下创建不同的layout文件夹,比如layout-640×360,layout-800×480,所有的layout文件在编译之后都会写入R.java里,而系统会根据屏幕的大小自己选择合适的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);
}