android程序界面自动适应屏幕分辨率例子
2015-04-29 00:00
363 查看
为不同分辨率的手机创建界面
1,首先进入res 文件夹下。
2,创建一个名为“layout-1024x768”文件夹,
其中1024x768 是屏幕分辨率的大小,值得注意的是分辨率中大的数字必须写到前面,否
则会产生语法错误。如layout-768x1024 的写法是错误的。
3,编写main.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:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
<TextView android:layout_width="fill_parent" android:id="@+id/tv"
android:layout_height="wrap_content" android:text="1024x768" />
</LinearLayout>
4,在按照上述创建layout-1280x800分辨率的文件夹,main.xml直接拷贝。
5,分别创建1024x768和1280x800的模拟器:
6,注意在AndroidManifest.xml中添加 <supports-screens android:largeScreens="true"
android:anyDensity="true" />否则,你的应用不会全屏。
详细见例子helloword。
7,最后,默认layout,不要删掉,如果指定分辨率不存在的时候,会默认调用layout中布局文件。如果删除,则报错。
1,首先进入res 文件夹下。
2,创建一个名为“layout-1024x768”文件夹,
其中1024x768 是屏幕分辨率的大小,值得注意的是分辨率中大的数字必须写到前面,否
则会产生语法错误。如layout-768x1024 的写法是错误的。
3,编写main.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:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
<TextView android:layout_width="fill_parent" android:id="@+id/tv"
android:layout_height="wrap_content" android:text="1024x768" />
</LinearLayout>
4,在按照上述创建layout-1280x800分辨率的文件夹,main.xml直接拷贝。
5,分别创建1024x768和1280x800的模拟器:
6,注意在AndroidManifest.xml中添加 <supports-screens android:largeScreens="true"
android:anyDensity="true" />否则,你的应用不会全屏。
详细见例子helloword。
7,最后,默认layout,不要删掉,如果指定分辨率不存在的时候,会默认调用layout中布局文件。如果删除,则报错。
相关文章推荐
- android程序界面自动适应屏幕分辨率例子
- android自动更新程序,安装完以后就什么都没有了,没有出现安装成功的界面的问题
- android自动更新程序,安装完以后就什么都没有了,没有出现安装成功的界面的问题
- android自动更新程序,安装完以后就什么都没有了,没有出现安装成功的界面的问题
- android自动更新程序,安装完以后就什么都没有了,没有出现安装成功的界面的问题
- Android程序跳过登录界面直接进入主界面(自动登录)
- android自动更新程序,安装完以后就什么都没有了,没有出现安装成功的界面的问题 .
- android自动更新程序,安装完成后没有出现安装成功的界面的问题
- android自动更新程序,安装完以后就什么都没有了,没有出现安装成功的界面的问题
- android程序自动适应屏幕大小
- android中程序更新下载完成后自动跳转安装界面
- android自动更新程序,安装完以后就什么都没有了,没有出现安装成功的界面的问题
- android中程序更新下载完成后自动跳转安装界面
- android屏幕分辨率详解 ldpi mdpi hdpi 程序UI自适应 《官方翻译》
- Android实现开机自动运行程序
- Android应用的自动升级、更新模块的实现完整方案+参考程序
- Android-开机自动启动程序并禁用返回键(BroadcastReceiver)
- NDK编译Android字符界面的可执行程序
- phoneGap中android程序自动更新代码(适合Android4.0之后版本)
- android中如何实现进入一个界面不做任何动作过10秒钟自动跳转到其他activity?