Placing correctly elements on all devices

Hello the community :slight_smile:
I’m facing an issue which is I guess the issue faced by every Android devlopper, placing elements at the good place :exploding_head:
Actually on my Galaxy S10+, I’ve placed my top FAB at (screen height - 5 - 55) and the following result is fine :


But while launching on a Galaxy A8, my top FAB seems to be to high in the screen and the result is that :

However, I used the screen height which should not be the same on every device and so, FAB should be at good place (60 from top border) :confused:

How can I do to place them correctly whatever the device, can anyone answer this and help me please ?
Do I have to place them at a % of the screen height instead ?
:pray:

Use floating button instead and use %

FAB from my side is Floating Action Button :slight_smile:

Try using percentage

May be these :point_down: topics can provide some help…

I know they are about centralizing fab but see if you get any idea by going through them once :slightly_smiling_face:

1 Like

I’ve read everyhting and this is how I calculate the margin…
offset from border is 0.5% of the biggest screen dimension (width or height)

On my S10+, button is correctly placed but on a Nexus, it looks like this

While doing some tests, it appears that Margin Right is ok but bug is coming from Margin Bottom (value seems too high !)
I’m lost :frowning:

Maybe the title bar’s height causing the problem? Should you exclude the height of title bar even?Just a guess though. I am not sure enough.

Thanks for your reply, there is no title bar in this screen but I suspect the system bar which is bigger in height that the Nexus.
By the way, I wonder what is behind screen height, does it includes the system bar and navigation bar or not ?

Sorry I saw that but was late for the reply

The height includes the status bar even see Boban’s reply here :point_down:

For navigation bar, I am not sure, because some devices out there have the navigation bar embedded in the hardware itself and it’s not on the software part. So in such cases height will only include status and title bar

1 Like

If you are using Google map component, then use it’s height instead of screen height…

2 Likes

Thanks a lot @Boban

Sometimes solution is in front of you and you can’t even see it ! :+1:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.