Android Question x,y float to percentage %

Douglas Farias

Expert
Licensed User
Longtime User
Hi all.
How can i convert x and y as float to percentage?

i have this panel
B4X:
Sub pFundo_Touch (Action As Int, X As Float, Y As Float)
    Log(x)
End Sub

i get this numbers when i log the (x)
953.1174926757812

how can i convert this number to %x or the y to %y?
all devices log diferent number on x and y, i think this is based on DIP.

thank you
 

emexes

Expert
Licensed User
You sure you need to convert it to % of screen? It feels like you're about to use the coordinates to plot stuff on the screen, in which case you might be better off leaving them as pixels, rather than converting back and forth.

Plus, pixels unlikely to be square in % units (although physical pixels might not be quite square either, but nowadays they're usually pretty close).
 
Upvote 0
Top