简体   繁体   English

Java android-适合具有不同屏幕尺寸的图像背景上的项目

[英]java android - fit items on a image background with different screen size

This is my first post and i have (i think) a uncommon request... 这是我的第一篇文章,我有一个不常见的要求...

I'm programming on the last Eclipse Mac, for every android SDK, and i'm using more XML for layout than runtime... So i search a solution in XML if possible. 我在最后一个Eclipse Mac上为每个android SDK编程,并且我使用的XML布局比运行时更多。因此,如果可能的话,我会搜索XML解决方案。

Here is the situation: i work with an image background wich simulate item like buttons, image, text... etc. On this image, i put buttons, image, and text (buttonview textview etc...) and place it precisely on their places on the image. 这是一种情况:我使用图像背景,并模拟按钮,图像,文本等项目。在此图像上,我放置按钮,图像和文本(buttonview文本视图等)并将其精确放置在他们在图片上的位置。 This solution is very powerful to have good design BUT, if i change the resolution of the screen, and/or its size, each item won't be at its place, and will be translated (horiz and/or vertic) for some "dp"... (and yes i use dp, not mm or px or whatever) 如果我更改屏幕的分辨率和/或其尺寸,则该解决方案对于拥有良好的设计功能非常强大,但是,如果没有更改每个项目,它都不会在其位置,而是会翻译(水平和/或垂直)一些“ dp“ ...(是的,我使用dp,而不是mm或px等)

I'm really embarrased because i think thanks to "dp" it keep proportionnality but.. not ! 我真的很尴尬,因为我认为多亏了“ dp”才能保持比例,但是..不!

My question is how can i fix my items at their places on the image background, for different screen size/resolution !! 我的问题是,如何针对不同的屏幕尺寸/分辨率在图像背景上的位置固定我的物品!

Thanks in advance everyone, My Best From Lyon,France 在此先感谢大家,我最好的法国里昂

First realise that if you want to make it pixel perfect for all screen sizes your out of luck. 首先要认识到,如果您想使其像素适合所有屏幕尺寸,那您真不走运。

Second accept that you can't make it perfect for all screen sizes. 其次,接受您不能完美地适合所有屏幕尺寸的想法。

Third you can get far with creating different layout for different screen sizes. 第三,您可以为不同的屏幕尺寸创建不同的布局而受益匪浅。 You can read a lot about supporting multiple screen sizes here . 您可以在此处阅读很多有关支持多种屏幕尺寸的信息 One important thing to take from here is that you can make layout for the different screen sizes or different density sizes. 从这里获得的重要一件事是,您可以为不同的屏幕尺寸或不同的密度尺寸进行布局。

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

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