简体   繁体   中英

placing images based on co-ordinate values randomly in android

I want to place images randomly based on the (x,y) co-ordinate values and that should compatible with all the devices having any screen resolution.

Give a clear description of co-ordinate system for any device screens.

Generate a random number between
0 to (screen width - image width) for x ,
and a random number between
0 to (screen height - image height) for y .

And set them as the x and y coordinates of your image. I don't feel any more explanation is necessary.

BTW, the coordinate system for mobile device is as follows.

  • Origin is at top left corner.
  • Value of x coordinate increases to the right
  • And that of y coordinate increases to the bottom.

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