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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:29:48+00:00 2026-06-01T16:29:48+00:00

New -> Android project for testing the problem Code for Test.java : package test.density.yeah;

  • 0
  1. New -> Android project for testing the problem
  2. Code for Test.java:

    package test.density.yeah;

    import android.app.Activity;
    import android.os.Bundle;
    
    public class TestActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        }
    }
    
  3. Code for main.xml:

    <ImageButton
    android:background="@null"
    android:src="@drawable/icon"
    android:layout_width="200dp"
    android:layout_height="200dp">
    </ImageButton>
    
  4. Started emulator with settings:

Resolution – 480×800

Avstracted LCD Density – 190

RESULT:

http://cs5961.userapi.com/u68152416/-3/y_ef134df2.jpg

After that I’ve started emulator with such settings:

Resolution – 480×800

Avstracted LCD Density – 240

RESULT:

http://cs5961.userapi.com/u68152416/-3/y_8b99507b.jpg

Emulator settings for the first test mathes my HTC HD2 characteristics and second is the same as the HTC Sensation XL is. When running this test app on them
it is the same problem. HD2 (480×800, 190dpi) – small image, Sensation (480×800, 240dpi) – huge image.

So why “density independent pixels” do not work?

  • 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-01T16:29:49+00:00Added an answer on June 1, 2026 at 4:29 pm

    It works fine, but there’s a twist you need to know about.

    You’re using the src attribute on the View. If you do that, the View will be sized according to the bitmap size, and you’d normally have different versions for the various densities, mdpi, hdpi, xhdpi etc. It will ignore layout_height and layout_width.

    If you want your View to ignore the bitmap size and use the layout_width and layout_height values to force the size, you need to use the background attribute, not src.

    <ImageButton
        android:background="@drawable/icon"
        android:layout_width="200dp"
        android:layout_height="200dp">
    </ImageButton>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My android app project need to add a new function of saving the click
The below code was automatically generated when I started a new android project. I'm
i am new in test android project. just i try to test sample hello
Im new to android. I have been writing my first app, I testing it
I'm trying to import GreenDroid into a new Android Project (SDK 2.2) and I'm
When I start a new Android project in Eclipse (Helios), the strings.xml has 2
I am a new android app developer and i want to use google map
I am new android app developer i want make app for tablets and phone
When creating a new android project, the build target has two choices: Android 2.2,
I am working on an Android project in Eclipse and debugging / testing using

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.