Android Screen Size Algorithm / Pattern

岁酱吖の 提交于 2019-12-02 01:32:57

It's no perfect solution that i've seen so far.

I came across this issue by specifying the position for the particular item for the specific screen ratio(native screen resolution in an emulator), then recalculate its position and scale it up/down when running it in the different screen size.

  displayXpos =  constDevelopmentScreenXpos (targetDeviceScreenHeight/constDevelopmentScreenHeight) etc..
  displayXScale = similarAlgorithm

This is not the best, but it give you some idea.

Also, i fill some 'limbo' area with a background and choose to not care it when the target device X:Y screen ratio is different from development device.

HTH

ya, it is better to use calculation in percentage

first get the total size avail of the screen, then calculate percentage on it and the place the control based on calculation

to get avail size

Display mDisplay= activity.getWindowManager().getDefaultDisplay();
int width= mDisplay.getWidth();
int height= mDisplay.getHeight();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!