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 8805185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:48:00+00:00 2026-06-14T01:48:00+00:00

When I’m placing pins in MapView by using ItemizedOverlay on my Android 2.2 phone,

  • 0

When I’m placing pins in MapView by using ItemizedOverlay on my Android 2.2 phone, the placement is right, but when I does it on my 4.0 and 4.1 phones, the placement is wrong. The pin is placed further down on the map, but with the same x-coordinate.

I figured out that the pixel value of the upper left corner in MapView on the 4.XX devices weren’t (0.0), as it was on my 2.2 device. I could see that the difference was the height of the action bar (like the one highlighted on the image), and found some code to get the height of it. Now, when placing the pins, I subtract the height of the action bar from the y-coordinates in MapView. I get the correct result on my 4.XX devices, but now the placement is wrong on my 2.2 device.

I have an add in the top of my screen, but it’s height is pretty much the same on all my devices.

Do you know what I should do to get the correct coordinates in MapView on all devices?

The code I used was:

final WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
final Display d = w.getDefaultDisplay();
final DisplayMetrics m = new DisplayMetrics();
d.getMetrics(m);
int totalHeight =mapView.getLayoutParams().height;
int statusbarHeight = totalHeight - mapView.getMeasuredHeight();

Example of action bar

  • 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-14T01:48:04+00:00Added an answer on June 14, 2026 at 1:48 am

    I solved the problem, but it isn’t most pretty solution.

    I check for the size of the action bar. If it exist, I run the code shown in the question. If the size returns null, which means that the action bar doesn’t exist, I don’t run the code.

    The code is:

    // Check if an action bar exist (Android 4.XX) 
    private void getActionBarHeight() {
        // TODO Auto-generated method stub
        final WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        final Display d = w.getDefaultDisplay();
        final DisplayMetrics m = new DisplayMetrics();
        d.getMetrics(m);
        actionBarHeight = m.heightPixels;
    
        try { // If the action bar exist
            TypedValue tv = new TypedValue();
            context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true);
            getResources().getDimensionPixelSize(tv.resourceId);
        } catch (Exception e) { // If it doesn't exist
            actionBarHeight = -1;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.