在dp中指定的边距在不同屏幕上的相对大小不同

时间:2012-05-23 03:30:29

标签: android user-interface scaling imagebutton

更新:我发现了我的问题。我为不同的分辨率定义了单独的可绘制资源,但我不知道我必须为不同的屏幕尺寸创建不同的布局。我想我应该更全面地阅读“支持多个屏幕”页面。有此问题的其他人,请阅读整个页面:

http://developer.android.com/guide/practices/screens_support.html#qualifiers

我的印象是,使用dp单元的目的是在不同的屏幕尺寸上使间距相同,但我有一个ImageButton,其宽度,高度,左边和顶边都用dp单位定义,并且当我在模拟器上循环浏览不同的屏幕尺寸时,按钮不会位于相同的相对位置。

我的ImageButton在xml文件中定义为:

<ImageButton
    android:id="@+id/routesButton"
    android:layout_height="33dip"
android:layout_width="90dip"
    android:src="@drawable/route_button"
    android:scaleType="fitCenter"
    android:background="#00000000"
    android:layout_gravity="top|left"
    android:layout_marginTop="280dip"
android:layout_marginLeft="15dip" />

我认为它可能与ImageButton有关,因为在dp中设置了边距的其他视图正在调整。我非常感谢任何帮助。感谢

1 个答案:

答案 0 :(得分:1)

我发现了我的问题。我为不同的分辨率定义了单独的可绘制资源,但我不知道我必须为不同的屏幕尺寸创建不同的布局。我想我应该更全面地阅读“支持多个屏幕”页面。有此问题的其他人,请阅读整个页面:

http://developer.android.com/guide/practices/screens_support.html#qualifiers