Center label on screen of any mobile

hi , I want to put the labels in the middle of the screen,
I did this, but on the main phone the value divided by height should be 2, and on the other phone it should be 1.25.

I want to be in the middle of whatever phone the app is used on

that is i want

.
.
.
blocks for my mobile

.
.
.
blocks for other mobile

why is there a difference? what happens, if you use 2 for all devices?
Taifun

in 1.25 device , when i use 2 , the label not be in the center

i’m sorry for my english

The 2 is the middle of the main phone.

And 1.25 is the middle of the other phone

Incidentally, the black image is a screenshot of the main phone that used the value 2

what happens, if you use Screen.Height?
the center of the screen is always the height divided by 2…
Taifun

@Taifun
blocks

not in the center :frowning:

Can you provide a demo.aia…

Also can you tell us what

  • Type/name of devices
  • Android version

android 7 android emulator memu
android 8 huawei y7 prime 2018

when i use value 2 , it be in center in emulator , but in y7 prime don’t be in center

t.aia (15.7 KB)

this the demo

Try this: t_2.aia (37.3 KB)

5 Likes

And here you have my contribution

4 Likes

What’s the point of using animation as it does nothing with those values…

Edit: I think I have figured out why

1 Like

I think its almost the same.

True - true

Note. animation component uses real px of the phone while you are feeding it with dp values…

That’s why we used density block

2 Likes

This works thanks, but I still don’t understand the benefit of the density block

Is there any article or video to explain it?

This also works a thank you

1 Like

i have a small Doubt :sweat_smile:

Can’t we do it in a Simpler way by keeping AlignVertical and AlignHorizontal to Center.

Sorry if i misunderstood something. :sweat_smile:

2 Likes

Of course.

1 Like

See here and watch the video:

2 Likes