`

android程序界面自动适应屏幕分辨率例子

 
阅读更多
为不同分辨率的手机创建界面

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,不要删掉,如果指
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics