简体   繁体   中英

Is using absolute positioning for image positioning bad?

I am working on an application that requires a lot images. I am currently positioning images by plugging numbers and debugging on my Nexus 3 to observe the positioning. Example:

g.drawString("START", 176, 550, paint);

Will this bite me in the future when I try to run the application on devices with different dimensions or will Android adjust for this. I am not looking to run this application on tablets, only phones. Is this bad practice? If so, how should I be programming positioning. Is it possible to return the dimensions of the device in order to adjust?

Yes, it will byte you. Those are pixels, how big the picture will be depends on the screen density. On a 160ppi screen, it will start 1 inch from the left. On a 320dp it will be 1/2 an inch. On a 480, 1/3. That may be ok, you'd have to answer that. But understand that on higher density screens you'll be closer to the left, unless you scale by density.

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