如何为android布局设计支持多个屏幕
问题描述:
我正在使用android2.2.I创建了drawable-mdpi,drawable-hdpi,res/drawable-xhdpi。 我创建了大,中,小屏幕大小的布局文件夹。我在清单文件中使用。即使我无法获得对多个屏幕大小的支持。例如,大,中,小屏幕大小的图像大小和布局边距保持不变。谁能帮我?如何为android布局设计支持多个屏幕
答
名称布局文件夹与布局小,布局正常,布局大,layoutxx.It工作根据移动dpi.It不依赖于屏幕大小。
答
如果你想为所有屏幕创建布局,你可以使用权重来管理它们。
此示例代码可能会帮助你。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.3"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:orientation="vertical"
android:weightSum="1.0">
</LinearLayout>
</LinearLayout>
阅读本http://developer.android.com/guide/practices/screens_support.html – 2012-07-31 08:08:54
我也只用一个布局文件夹 – 2012-07-31 08:10:20
没有,你应该使用多个布局文件,布局XLARGE土地进行了测试,layout-xlarge,layout-land,layout-port like this – 2012-07-31 08:11:50