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.
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.
Yes, you can change the background color in camera/camera.py by editing the background_color key in the camera config dictionary.
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.
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.
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With