Android Question random label

Douglas Farias

Expert
Licensed User
Longtime User
how can i put a label random position on my screen

for exemple when start the app show

10% top 10% left

or 20% top
etc
random
its possible?
 
with Label1.Left = caca&"%y" xD
CACA is a random rnd(0,99) result

and this dont work
Rnd(0,99)%y
 
Upvote 0
if help someone ;)

Code: Copy
Dim lado,alto As Int
lado = GetDeviceLayoutValues.Width
alto = GetDeviceLayoutValues.Height
r1 = Rnd(0,lado)
r2 = Rnd(0,alto)

    Label1.Left = r1
    Label1.top = r2
 
Upvote 0
Just limit the width and height so the label doesn't disappear off the screen:

Code: Copy
r1 = Rnd(0,lado - Label1.Width)
r2 = Rnd(0,alto - Label1.Height)
 
Upvote 0
xD
when I went to post you posted first
thx man

i see this problem because i have my label out of screen
 
Upvote 0
Back
Top