0

My app works perfectly in resolution 480x800. If I keep the 480x800 resolution but change the screen size to for example 2.7 inches, 3.7 inches or 5.4 inches it still is perfect. But when I change the resolution to for example 640x1066 all the ImageButtons is too small and in the wrong place in all screen sizes... I have created ImageButtons in all four folders(drawable-l, m, h, xh) but still the buttons is not in the correct size..

<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" />

NOTE: My problem is not when I change screen size, but when I change screen resolution.

4

2 回答 2

0

您使用的是 9 个补丁图像吗?

当涉及到图像按钮之类的东西时,它们的工作要好得多,请在 Android 文档中查看它们。

于 2012-10-13T11:59:02.007 回答
0

是的,当然它会改变。您给出的边距(左,上)dp因分辨率而异。为避免此问题,您应该进行动态计算,例如动态获取屏幕高度和宽度并相应地设置边距。

于 2012-10-13T12:02:46.980 回答