Android上的多屏幕支持
从前几天我试图创建一个应用程序,可以根据模拟器的大小更改调整屏幕..我发现使用多个屏幕的解决方案。Android上的多屏幕支持
但我无法做到这一点 我已经从this接受了帮助,但无法理解我怎么能setContentView(R.layout.main);
?因为当我R
后,按。(点)不告诉我这个文件夹下面.. :( 我创建了res
文件夹下的layout-large
,layout-small
和layout-large-land
3个文件夹在我的Android应用程序
我已经添加到这一点我的清单文件..
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true" />
我是缺少在这里什么事?我在提前采用了android 1.6的感谢 的问题是我是否已经提供这main.xml
文件默认layout folder
也?是的话那么在屏幕尺寸CHAGE没有影响没有那么它关闭我的应用程序强制我已经使用API level 7
也不过问题试图保持相同 这是我的xml文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:id="@+id/rl"
android:layout_height="360dip">
<!--
<WebView android:id="@+id/webviewHelp"
android:layout_width="fill_parent"
-->
<!-- android:layout_height="fill_parent" />-->
<WebView android:id="@+id/webviewHelp" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<Button android:id="@+id/My_btn"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:gravity="center"
android:textSize="8px" android:text="Download this mp3 file"
android:textColor="@color/white" android:layout_width="fill_parent"
android:layout_height="28dip" android:visibility="invisible" />
<Button android:id="@+id/My_btn1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:text="this is button !"
android:layout_width="0dip" android:layout_height="0dip"
android:visibility="invisible" />
</RelativeLayout>
请您之前在这些文件夹中添加一些布局个XML在R之后键入点号:) 这些文件夹本身不会生成资源ID,但其中的xml文件却可以。
但这个文件必须在m布局文件夹中吗?其他应用程序强制关闭,如果我提供,然后它采取它并显示在屏幕视图更改没有更改我更新的代码 – Android 2011-06-13 06:05:17
查看我的更新的代码 – Android 2011-06-13 06:16:08
您将不同的布局文件放在不同的文件夹,Android运行时选择文件夹中的一个其名称与当前设备屏幕显示度量和方向相匹配。 例如:'setContentView(R.layout.main);'如果设备有* large *屏幕并且当前处于* portrait *方向或文件夹中,''会将main.xml加载到'layout-large-port'文件夹中如果当前具有*小*屏幕并且处于*横向*方向,则布局小陆地。如果Android在所需文件夹中找不到名为main.xml的文件,则在这两种情况下都会引发异常。 – 2011-06-13 09:35:31
的setContentView(R.layout.main)将是相同的。根据模拟器的大小,android会假定要考虑哪个文件夹。 – Lavanya 2011-06-13 05:31:14
它不会显示任何文件夹名称,但默认布局,它不是你的头痛,Android会自动选择合适的文件夹 – ingsaurabh 2011-06-13 05:31:52
查看我更新的代码 – Android 2011-06-13 06:11:34