简体   繁体   中英

Android: Scaling According to Screen Size

I'm building a game (similar to ye olde bricke breakerr but a fair bit different) in which everything ranging from the brick size to the brick spacing to the paddle size to the paddle positioning to the text display has to be dependent on the screen dimensions of the user.

I'm aware of 2 techniques of doing this:

1) Creating a few generic layouts that the program can select based on dimensions
2) Scaling everything by multiplying by USER_SCREEN_AREA/MY_SCREEN_AREA

Obviously, both these methods are rather difficult to implement. What I'm asking is if there is a simpler way to do this... If there isn't, do tell me so as well so I may go and implement the 2nd option which seems better to me..

May be this is what you looking for-

//using 'getsize' for custom resolution  
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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