我的应用完美解析度480x800。如果我保持480x800分辨率,但将屏幕尺寸改为例如2.7英寸,3.7英寸或5.4英寸,它仍然是完美的。但是,当我将分辨率更改为例如640x1066时,所有ImageButtons都太小,并且在所有屏幕尺寸的错误位置......我在所有四个文件夹(drawable-l,m,h,xh)中创建了ImageButton,但仍然是按钮是不是在正确的大小..Android屏幕尺寸分辨率
<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布局,以便我们可以看到您正在做什么来定位按钮。 – kabuko
我使用android:layout_marginLeft和marginTop将按钮放在相对布局中,我应该使用其他的东西吗? – Peter
取决于...你想要所有的按钮相对于左侧和顶部?或者更可能的是,你是否想要一些相对于左边/顶部相对于底部/右边?没有一个神奇的布局可以让你理解。您必须为设计使用适当的布局。 – kabuko