简体   繁体   English

如何将图像定位在所有android设备的同一位置?

[英]How to position images at the same spot all android devices?

I have to position the images on my layout such that it does not change its position with varying screen resolutions. 我必须将图像放置在布局上,以使其不会随着屏幕分辨率的变化而改变其位置。 They should be exactly where they are placed. 它们应该准确地放置在它们的位置。 layout_weight attribute can be used with linear layout. layout_weight属性可以与线性布局一起使用。 But I am using relative layout and I am dealing with cropped images. 但是我正在使用相对布局,并且正在处理裁剪的图像。 Any solution on how to position the image views? 关于如何定位图像视图的任何解决方案? Setting out margin height and width is not worth. 设置边距的高度和宽度是不值得的。

In short - you can't. 简而言之-您不能。 Devices have different resolutions as well as screen sizes ratio. 设备具有不同的分辨率以及屏幕尺寸比率。 Thus it's impossible for the app to look same because there is no same definition in Android. 因此,应用程序看起来不可能same因为Android中没有same定义。 The only way to design an interface - is to use bindings to other objects or parent view's borders. 设计界面的唯一方法-是使用对其他对象或父视图边框的绑定。 Try to investigate what are the rules, eg "to the bottom of the picture with 10dp gap" or "next to the TextView" - and it's the constants that are kept on every device. 尝试研究什么规则,例如“到图片底部有10dp间隙”或“紧挨TextView”-这是每个设备上保留的常量。

I can't imagine a scenario where this makes sense but it obviously must exist since the Android team built support for it. 我无法想象有一个合理的方案,但是显然它必须存在,因为Android团队已经建立了对此的支持。 The docs on the dimension type clearly state that it supports "mm" and "in" as qualifiers for millimetres and inches respectively. 尺寸类型上的文档明确指出,它分别支持“ mm”和“ in”作为毫米和英寸的限定符。

That should get you what you need but I would advise reevaluating that requirement, as it would make design a massive pain. 那应该可以满足您的需求,但我建议您重新评估该要求,因为这会使设计感到痛苦。

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

相关问题 在所有设备上将图像定位在同一位置的最佳方法? - Best way to position image in the same spot on all devices? 所有android设备的特定图像位置 - particular images position for all android devices Android如何定位元素以支持所有设备 - android how to position elements to support in all devices 所有Android设备上的UI元素(按钮,图像按钮)的位置相同 - Same position for UI elements (buttons, image buttons) on all android devices 如何在所有设备上看起来相同的边距处放置视图? - How to position the view with margin that will look same for all devices? 在所有Android设备上显示图像 - Display images on all android devices 如何在Android中保持所有设备尺寸的图像位置和大小? - how to maintain the Image Position and Size for all size of Devices in android? 如何为所有 android 版本和设备在存储中保存图像 - How to save images in storage for all android versions and devices 当我在 listView 中更改 position 图像时,所有甚至 listView 的图像在 android Java 中都变得相同。 与奇数 position 图像相同 - When I changed even position image in listView then images of all even listView become same in android Java. Same with odd position images 如何使应用程序在所有设备上看起来都一样 (android) - How to make a app scale the look the same on all devices (android)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM