Android屏幕尺寸和分辨率

时间:2012-10-13 11:54:53

标签: android xml drawable resolution screen-size

我的应用程序在480x800分辨率下完美运行。如果我保持480x800的分辨率,但将屏幕尺寸更改为例如2.7英寸,3.7英寸或5.4英寸,它仍然是完美的。但是当我将分辨率更改为例如640x1066时,所有的ImageButton都太小而且在所有屏幕尺寸的错误位置...我在所有四个文件夹中创建了ImageButtons(drawable-l,m,h,xh)但仍然是按钮的大小不正确..

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

注意:我的问题不是在我更改屏幕尺寸时,而是在我更改屏幕分辨率时。

2 个答案:

答案 0 :(得分:0)

您使用的是9张补丁图片吗?

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

答案 1 :(得分:0)

是的,它会改变。您在dp中给出了边距(左侧,顶部),这取决于分辨率。要避免此问题,您应该进行动态计算,例如动态获取屏幕高度和宽度以及相应地设置边距。