简体   繁体   English

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

[英]margins specified in dp are NOT the same relative size on different screens

UPDATE: I figured out my problem. 更新:我想出了我的问题。 I had defined separate drawable resources for different resolutions, but I was not aware that I had to create different layouts for different screen sizes. 我为不同的分辨率定义了单独的可绘制资源,但是我不知道我必须为不同的屏幕尺寸创建不同的布局。 I guess I should have read the "Supporting Multiple Screens" page more fully. 我想我应该更完整地阅读“支持多屏”页面。 Anyone else with this problem, read the ENTIRE page: 遇到此问题的其他任何人,请阅读整个页面:

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

I was under the impression that the purpose of using the dp unit was to make spacing the same on different screen sizes, but I have an ImageButton which has width, height, left, and top margins all defined with dp units, and when I cycle through different screen sizes on the emulator, the button is not positioned in the same relative place. 我给人的印象是使用dp单位的目的是在不同的屏幕尺寸上使间距相同,但是我有一个ImageButton,它的宽度,高度,左和上边距都由dp单位定义,并且在我循环时通过在模拟器上使用不同的屏幕尺寸,按钮不会位于相同的相对位置。

My ImageButton is defined in the xml file as so: 我的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" />

I'm thinking it might have something to do with ImageButton because other views with margins set in dp are adjusting properly. 我认为这可能与ImageButton有关,因为其他在dp中设置了边距的视图正在正确调整。 I'd greatly appreciate any help. 我将不胜感激任何帮助。 Thanks 谢谢

I figured out my problem. 我发现了我的问题。 I had defined separate drawable resources for different resolutions, but I was not aware that I had to create different layouts for different screen sizes. 我为不同的分辨率定义了单独的可绘制资源,但是我不知道我必须为不同的屏幕尺寸创建不同的布局。 I guess I should have read the "Supporting Multiple Screens" page more fully. 我想我应该更完整地阅读“支持多屏”页面。 Anyone else with this problem, read the ENTIRE page: 遇到此问题的其他任何人,请阅读整个页面:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM