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

  • Home
  • SEARCH
  • 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 8035509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:20:05+00:00 2026-06-05T02:20:05+00:00

my question has to do with using different layouts for different screen densities on

  • 0

my question has to do with using different layouts for different screen densities on the Android platform.

Let’s say that I have four main.xml files (each in their respective folders for their corresponding screen densities: ldpi, mdpi, hdpi, and xhdpi) and let’s say that they’re all identical to start with. But let’s say I want to get rid of some of the UI elements for the ldpi layout. How do I handle things on the Java side to avoid a null pointer exception when it tries to find that view in the ldpi layout on a ldpi phone? Should I just check and see if findviewbyid returns null and move on from there?

I realize that you’re supposed to keep things uniform in your apps, but on occasion it just seems like it’d make more sense to just get rid of a convenient but otherwise unnecessary UI element. I love having the extra real-estate on these new phones, but if/when it comes time to make a ldpi layout, I’d rather not just cram everything in there when it’d look better just to get rid of some stuff, if that makes any sense!

  • 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-05T02:20:07+00:00Added an answer on June 5, 2026 at 2:20 am

    It is a Good question. Null checking can be one of the solutions.
    another solution is checking screen properties. look at this example:

    public static boolean isTabletPC(Context context) {
            boolean isHoneycomb = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
            boolean hasLargeScreen = (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)
                    >= Configuration.SCREENLAYOUT_SIZE_LARGE;
            return isHoneycomb & hasLargeScreen;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a survey tool that will have different layouts and 'inquisitorial' processes
An answer to this question has led me to look into using Event Tracing
This question has been asked in various forms in a number of different forums,
The question has two parts, one of which I already have the answer for.
Ok, so I know this question has been asked in different forms several times,
Total beginner question about jQuery: I have a Form that contains several TextBoxes (input
It's very sad to say that this question was asked several times and never
This question has been asked before but in a slightly different way and I
I realize this question has been asked many times and I am have looked
Experimenting using different approaches and reducing code maintenance I have ended up using reflection

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.