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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:18:16+00:00 2026-06-15T23:18:16+00:00

Based upon Romain Guy’s blog post Android Performance Case Study when talking about Overdraw

  • 0

Based upon Romain Guy’s blog post Android Performance Case Study when talking about Overdraw he says this:

Removing the window background: the background defined in your theme is used by the system to create preview windows when launching your application. Never set it to null unless your application is transparent. Instead, set it to the color/image you want or get rid of from onCreate() by calling getWindow().setBackgroundDrawable(null).***

However getWindow().setBackgroundDrawable(null) seems to have no effect. Here’s a sample with the code:

//MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
    getWindow().setBackgroundDrawable(null);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}

// main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="#FFE0FFE0"
tools:context=".MainActivity" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="40dp"
    android:layout_marginRight="40dp"
    android:background="#FFFFFFE0" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dp"
        android:text="@string/hello_world" />
</LinearLayout>

// styles.xml
<style name="AppTheme" parent="AppBaseTheme">
   <item name="android:windowBackground">@color/yellow</item>
</style>

This sample produces the results in the image. You can see the outerlayer has an overdraw and the window background color is still visible. I expected the window’s background to be gone and only the lineralayout to have overdraw.

enter image description here

  • 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-15T23:18:18+00:00Added an answer on June 15, 2026 at 11:18 pm

    Just move getWindow().setBackgroundDrawable(null) down, until anywhere after setContentView(R.layout.main); e.g.:

    @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        getWindow().setBackgroundDrawable(null);
    }
    

    The setContentView(...) call propagates setting the content on the window the activity is attached to and probably overrides the change you meant to made with setBackgroundDrawable(null).

    Result:

    enter image description here

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

Sidebar

Related Questions

I found this thread about picking the closest/nearest value from an array based upon
I've got an oDate source based upon WCF data services. When I browse to
i want to sort dictionary based upon value of each dictioanry item.but if i
I'd like to update a page based upon the results of multiple ajax/json requests.
I have a Tabular type Form based upon a SELECT * FROM table type
I want to assign categories based upon the format of the book that will
I have a need to sort a collection of these based upon criteria determined
I am working on an asp.net web site that is based upon a single
I have some code in method C that will get executed based upon the
I have an enum. Based upon the value brought by model, I have to

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.