预缩放和支持不同大小的屏幕Android

时间:2012-05-22 09:18:07

标签: android screen screen-resolution

我正在阅读http://developer.android.com/guide/practices/screens_support.html并尝试了解预缩放的工作原理。

我有以下布局文件,该文件针对galaxy选项卡进行了优化:

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativelayoutmain"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/mainmenu"
>
<ImageButton
android:id="@+id/start_button"
android:layout_marginLeft="150dip"
android:layout_marginTop ="70dip"
android:layout_width="500dip"
android:layout_height="214dip"
android:background="@drawable/startsession"
android:contentDescription="@string/descbuttonstart"
/>

我已将屏幕图像放在drawable-ldpi文件夹中。问题是,当我在较小的屏幕上测试应用程序(使用模拟器)时,屏幕无法正确缩放 - 按钮很大并且定位不正确。

是否可以只为所有屏幕设置一个布局文件,如果是这样,那么这个工作的秘诀是什么?

谢谢。

2 个答案:

答案 0 :(得分:0)

屏幕尺寸和屏幕分辨率是两个独立的事情。 ldpi文件夹中的资源用于低分辨率,而不是必需的小屏幕尺寸。我更喜欢的方法是定义高分辨率的资源,让它们缩小其他资源。

答案 1 :(得分:0)

不,AFAIK它不可能你需要有三个不同尺寸的文件夹(hdpi,mdpi,ldpi),按钮,图像等具有不同的尺寸 再次布局你需要有三个布局文件夹(布局小,布局中,布局大)