我在/ res目录中有以下文件夹以支持不同的屏幕密度和方向。Android操作系统无法识别方向更改
/layout
/layout-land
/layout-small
/layout-small-land
/layout-large
/layout-large-land
在上述XML中,所有不同的是组件之间的对齐。例如,在人像:
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/linearLayout3"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@+id/linearLayout3" />
而在景观,
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/linearLayout3"
android:layout_marginLeft="60dp" //widens the margin space
android:layout_toRightOf="@+id/linearLayout3" />
然而,当方向改变时,正在使用相应肖像XML。
这里是AndroidManifest代码片段。
<activity
android:name=".MyActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" />
我与Android 2.2和3.7" 测试的应用程序在仿真器屏幕。有什么我错过了?
在全部文件夹中是否有布局xml?我的意思是,你确定你正在工作正确的目录吗? – Talha 2013-02-11 13:03:14