Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8518723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:03:45+00:00 2026-06-11T06:03:45+00:00

I have been trying to find out how android relocates UI elements on different

  • 0

I have been trying to find out how android relocates UI elements on different screens for the same application. I’ve been doing some tests with Android 2.2’s music player:
Android 2.2 music player
(source: simplehelp.net)

Here is the position(top left corner) for the first image button of the MediaPlaybackActivity in different screen sizes:
Screen 1 (resolution: 480×800, density: 240dpi): coordinates in px: 345, 109
Screen 2 (resolution: 240×400, density: 120dpi): coordinates in px: 173, 53
Screen 3 (resolution: 320×480, density: 160dpi): coordinates in px: 230, 46

My question is: given the coordinates of a UI element (the button in this case) in any screen, is it possible to predict the coordinates of that element on the other two screens?
I’ve tried converting from px to dp and then back to px but it doesn’t work (though is close), here is what I’ve tried:

location of image button with index 0 in screen 2 in px: 173, 53
location of image button with index 0 in screen 2 in dp: 230.66, 70.66 () (I use this formula: px = dp * (dpi / 160) which I found here)
location of image button with index 0 in screen 1 in px: 346, 106

You can see that here is quite close but when using this same formula to convert px from screen 1 to screen 3 I get: 230, 72.66, so you can see that the difference in the y axis is quite big. I suppose the upper bar affects the y axis but I don’t understand why such a difference.

I’m I doing something wrong here? is there a way to predict the new location and size of UI elements?, how does Android relocates the views?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:03:47+00:00Added an answer on June 11, 2026 at 6:03 am

    I think I know why the calculation failed. I created a simple app and let android do the scaling by itself, then applied the formula and it worked. So I guess that the application I was using (music player) might be customized to display differently on different screens, even though it looks quite the same. And since developers can used different layouts for different screens then I guess the problem is not as simple as I thought.
    Thanks @aprian, your comment helped me to find out what might be the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to find out how game engines deal with asset compression.
I have been trying to find out why the following lines of code do
I have been trying to find out what the difference is between the IS
I have been struggling for a few days trying to find out how come
I have been trying to find some resource on this topic for a while
I have been trying to find out if MSbuild can send an email to
I have been trying to find out more about Voldemort but it doesn't seem
I have been trying to find out total count of rows in each tables
I have been trying to find out how to populate a dropdown box in
I have been trying to find out the problem to this for a day

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.