Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set initial background color before loading

How can I set background color of an activity before setContentView. I have an activity which takes lot of time to load, I need to keep background white until activity finishes loading.

like image 670
AVEbrahimi Avatar asked May 14 '15 05:05

AVEbrahimi


People also ask

How do I change the default background color in HTML?

To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a table, heading, div, or span tag.

How do I change my main background color?

Yes, you can change the background color in camera/camera.py by editing the background_color key in the camera config dictionary.

How do you override background color in CSS?

If that class has a background-color of blue, and you want your <div> to have a red background instead, try to change the color from blue to red in the class itself. You could also create a new CSS class that defined a background-color property with a value of red and let your <div> reference that class.

Which tag can set the background color?

To set the background color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <body> tag, with the CSS property background-color.


1 Answers

I guess this is exactly what you need.

First define the color in values/colors.xml

<resources>
    <color name="background">#FFFFFF </color>
</resources>

Create a themes.xml file in res/values that references that color:

<resources>
 <style name="MyTheme" parent="@android:style/Theme.Light"> 
  <item name="android:windowBackground">@color/background</item>
 </style>
</resources>

... and then in your AndroidManifest.xml specify this as the theme for your activity to use.

<activity
        android:name=".MyActivity"
        android:theme="@style/MyTheme" />
like image 98
Narendra Singh Avatar answered Sep 25 '22 07:09

Narendra Singh