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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:42:33+00:00 2026-05-30T21:42:33+00:00

My splash screen stretches badly when I run my app , so I tried

  • 0

My splash screen stretches badly when I run my app , so I tried a solution on one of the questions here to manually adjust dither and purge like so

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        BitmapFactory.Options myOptions = new BitmapFactory.Options();
        myOptions.inDither = true;
        myOptions.inScaled = false;
        myOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
        myOptions.inDither = false;
        myOptions.inPurgeable = true;
        Bitmap preparedBitmap = BitmapFactory.decodeResource(getApplication()
                .getResources(), R.drawable.bg, myOptions);
        Drawable background = new BitmapDrawable(preparedBitmap);
        ((LinearLayout) findViewById(R.id.layout_main))
                .setBackgroundDrawable(background);

Instead of putting the image of the splash which causes bad stretching I am setting the background and configuring options.
My xml looks like this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:id="@+id/layout_main">
</LinearLayout>

I tried Clean+rebuild+refresh but still I get a NullPointerException at

((LinearLayout) findViewById(R.id.layout_main))
                .setBackgroundDrawable(background);

It cannot find the linear layout. Any ideas? Help!

  • 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-30T21:42:34+00:00Added an answer on May 30, 2026 at 9:42 pm

    I solved this by adding some dummy content like imageview with src = @null to the layout. Otherwise the layout did not inflate. After that I did what I was doing and voila. Moral: To inflate a layout that you want to find programmatically – add some dummy content and not just the layout (I dont know what the official docs say, but this is what I ve found in my case)

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

Sidebar

Related Questions

I have an app that displays a splash screen. The splash screen activity creates
I created my splash screen using the method mentioned here: http://delphi.about.com/od/formsdialogs/a/splashscreen.htm I need to
I want to implement a splash screen for my app, i'm using this code
I have developed application in Android and designed one splash screen image of size
I recently added a splash screen to my WPF app.My app loads fast so
To implement my splash screen for my app, I'm starting a thread from main
My splash screen is working, but my app works on landscape mode, and the
I am creating a splash screen for my BlackBerry app. Right now the image
I have a question that I have a splash screen in my android app
I have created a splash screen for my app to hide the periodic insertion

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.