I want a text to have relatively same size in every Android device.
I have a canvas (fullscreen). In middle of this canvas is some text. This text fills 20% of my screen leaving 40% for both sides. I want these precentages to be true when text is viewed in any Android device.
I also want the same thing vertically.
使用“ sp”单位将尺寸放入Dimension资源中 。
I decided to measure width of text in pixels and save that value.
When text is loaded in different resolution, I multiply the original pixels with scale of resolution change. I loop up from text size one, always calculating new resolution and checking which matches the original resolution best.
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.