【发布时间】:2012-10-12 17:48:46
【问题描述】:
我的应用在 480x800 分辨率下完美运行。如果我保持 480x800 分辨率但将屏幕尺寸更改为例如 2.7 英寸、3.7 英寸或 5.4 英寸,它仍然是完美的。但是,当我将分辨率更改为例如 640x1066 时,所有的 ImageButton 都太小了,并且在所有屏幕尺寸中都位于错误的位置......我已经在所有四个文件夹(drawable-l、m、h、xh)中创建了 ImageButtons 但仍然是按钮的大小不正确..
<ImageButton
android:id="@+id/ib1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="433dp"
android:background="@drawable/imagebutton1" />
<ImageButton
android:id="@+id/ib2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="188dp"
android:layout_marginTop="436dp"
android:background="@drawable/imagebutton2" />
注意:我的问题不是我改变屏幕尺寸,而是我改变屏幕分辨率。
【问题讨论】:
-
您是否确定使用
dp而不是px来指定明确的宽度和高度?您可能还想发布您的 XML 布局,以便我们可以看到您为按钮定位所做的工作。 -
我使用 android:layout_marginLeft 和 marginTop 将按钮正确放置在相对布局中,我应该使用其他东西吗?
-
取决于...您是否希望所有按钮都相对于左侧和顶部?或者更有可能的是,您是否希望一些相对于左/上一些相对于下/右?没有一种神奇的布局会读懂你的想法。您必须为设计使用适当的布局。
-
但我的问题不是我改变屏幕尺寸,而是我改变屏幕分辨率
标签: android size screen drawable resolution