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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:31:50+00:00 2026-05-27T18:31:50+00:00

I am working on an android app in which I am seeing some disparity

  • 0

I am working on an android app in which I am seeing some disparity between what is showing up on the actual device and what is showing up when I run the app on the emulator.

Here is the relevant code.

I have an xml file which defines a shape – a simple blue rectangle:

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <corners
        android:radius="4dp" />
    <gradient
        android:angle="270"
        android:startColor="#449def"
        android:endColor="#2f6699" />
    <stroke
        android:width="1dp"
        android:color="#2f6699" />
</shape>

I then have another “view” xml file which uses that shape, shown here:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

     <View
         android:background="@drawable/blue_rectangle"
         android:layout_width="match_parent"
         android:layout_height="match_parent" 
     />

</LinearLayout>

Finally, I have a custom ViewGroup which extends RelativeLayout. This custom layout has a child view object of the view which I described above. The custom layout also overrides the onLayout method such that it handles the layout process itself. That code is here:

@Override
protected void onLayout(boolean arg0, int arg1, int arg2, int arg3, int arg4) 
{   
    //Layout the children of this viewgroup
    int childCount = this.getChildCount();
    for (int i = 0; i < childCount; i++)
    {
        NodeView view = (NodeView) this.getChildAt(i);
        view.layout(40, 40, 40, 40); //Hard code the child object position
    }
}

As you can see, I am hardcoding the child views to have position (40, 40) and have width and height of 40 dip.

Unfortunately, I am getting varying results. This is what it looks like on the Android emulator (part of the Android development tools):

Android emulator output

This is what it looks like on my actual Android device (and this is what I want it to look like as well):

Android device output

What is causing the disparity in size of the blue box? Any ideas? Thanks!

  • 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-05-27T18:31:51+00:00Added an answer on May 27, 2026 at 6:31 pm

    The emulator has a setting when you make your AVD called Abstracted LCD Density. Make sure that is set to the same as the device. See if that works.

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

Sidebar

Related Questions

I am working on an android app in which I am using some Native
I working on an android app which can benefit from device information. Like make,
I'm working on an Android app in which I would like to use multi-touch.
i am beginner in Android app development i am working on a app which
I am working on an Android app where we enter some text in edit
I am currently working on an Android app and I am having some issues
I am working on an Android app which runs a periodic service (every 15
I am working on an android app in which i have to fetch data
I am creating an android app which pulls in RSS Feeds from here http://spaceflight1.nasa.gov/realdata/sightings/cities/rss/index.cgi?country=United_Kingdom&region=England&city=Manchester
I'm working on an android app which has different layouts for phone vs tablet.

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.