Android theme: Whole screen becomes white - android

I am doing a simple customization to my app where I want to add a custom background color to Action Bar. Here is my styles.xml in styles-v14 folder. (My app is targeting only SDK 14 and above).
If I simply uncomment this line and run my app , the whole screen becomes white except status bar while I expect the Action Bar background color to be of different color.
<!-- <item name="android:actionBarStyle">#style/WindowTitleBackground</item> -->
Any idea what is going wrong. Here is my App manifest:
<application
android:name=".App"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
styles.xml
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:listChoiceIndicatorSingle">#drawable/btn_radio_holo_light</item>
<!-- <item name="android:actionBarStyle">#style/WindowTitleBackground</item> -->
</style>
<style name="RadioButtonAppTheme" parent="android:Widget.CompoundButton.RadioButton">
<item name="android:button">#drawable/btn_radio_holo_light</item>
</style>
<style name="WindowTitleBackground">
<item name="android:background">#color/titlebackgroundcolor</item>
</style>
</resources>

Try adding parent attribute in your ActionBar style
<style name="WindowTitleBackground"> parent="#android:style/Widget.Holo.ActionBar"
<item name="android:background">#color/titlebackgroundcolor</item>
</style>

Related

Change button background color in entire project in Android

I'm making an Android app, but I cannot change the default background color of all buttons in the project.
The only way I can do it is by changing them one by one.
Is there any other way?
Set buttonStyle in your Theme.
like following:
(I assume that you use AppCompat)
In your style.xml:
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
...
<item name="buttonStyle">#style/YourButtonStyle</item>
<!-- For preview -->
<item name="android:buttonStyle">#style/YourButtonStyle</item>
</style>
<style name="YourButtonStyle" parent="#style/Widget.AppCompat.Button">
<!-- Set background -->
<item name="android:background">#drawable/your_button_drawable</item>
</style>
</resources>
In your AndroidManifest.xml:
<application
...
android:theme="#style/AppTheme" >

Android black screen before Splash screen in Kitkat version

In my Android application I seen black screen before splash screen so that I
have customized app theme as follows:
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- my custom theme. -->
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#drawable/splash1</item>
</style>
the following is work for API version 20 and below version but in kitkat version (API version 21) it open the my splash screen two times.
I could not get solution after working long time. Please help me on this.
I am getting blank screen and i found the issue that "A TaskDescription's primary color should be opaque", means you have to replace your colorPrimary and colorPrimaryDark to 6 digits,
example: if you take colorPrimary = #4D607D8B remove "4D" and finally it is #607D8B. you can refer this link: https://stackoverflow.com/a/29166908/2897365
Try this,
Add a theme with the same background you are using into your application tag in the manifest file to prevent the black screen to be drawn.
theme.xml
<resources>
<!-- Base application theme is the default theme. -->
<style name="Theme" parent="android:style/Theme" />
<style name="Theme.MyAppTheme" parent="Theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#drawable/my_app_background</item>
</style>
</resources>
AndroidManifest.xml
<application
android:name="#string/app_name"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.MyAppTheme" >

how to change color of background in menu?

How to change color of background in menu? It is white by default. I changed style.xml and menu but it shows white menu yet.
what is problem with this code:
I can remove
android:theme="#style/your_custom_optionsMenuStyle"
form manifest.xml and the menu color become black. but i want to know is it good way? and is it be black in other devices with different api?
<item
android:id="#+id/menu_settings"
android:title="#string/menu_settings"
android:orderInCategory="100"/>
<item name="actionOverflowMenuStyle">#style/your_custom_optionsMenuStyle</item>
</menu>
style.xml file:
<
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="your_custom_optionsMenuStyle" parent="AppBaseTheme">
<item name="android:popupBackground">#000000</item>
</style>
</resources>
manifest:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/your_custom_optionsMenuStyle"
>
You can override menu style in your app theme from styles xml file using attribute
<item name="actionOverflowMenuStyle">#style/your_custom_optionsMenuStyle</item>
where your_custom_optionsMenuStyle specifies the behaviour of each menu attribute
<style name="your_custom_optionsMenuStyle" parent="Widget.AppCompat.PopupMenu.Overflow">
<item name="android:popupBackground">your color code</item>
</style>
You need to set style on icons.I prefer to see below link will help How to change the background color of Action Bar's Option Menu in Android 4.2?

Changing Android action bar background colour

For some reason this setup just gives me the default action bar background colour.
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#d73830</item>
</style>
</resources>
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
...
</application>
In activity_main.xml my theme is set to 'AppTheme'.
You have wrong parent of MyActionBar.
It must be from AppCompat, like next:
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background" tools:ignore="NewApi">#color/red</item>
<item name="background">#color/red</item>
</style>
What you can do is to use hash code of colour.Here is how.Go to this web page
http://www.color-hex.com
Choose a colour you wish and after copy the code of that colour and later paste into your background section.In general lets say you want your background colour of your screen to be red so you must declare it in xml layout file like this
android:background = "#FF0508"/>
You can declare this code almost everywhere where you want to change exact things colour and for my opinion its the easiest way.Why not?you got a webpage where you can get colour code and you can use it with a single line everywhere.Delicios isn't it?

Trying to set the background of android actionbar version 2.1 or so (API 7) and up

Alright so I've followed android tutorial to try and style my action bar and it doesn't seem to work
themes.xml
<resources>
<!-- the theme applied to the application or activity -->
<style
name="CustomActionBarTheme"
parent="#style/Theme.AppCompat.Light.DarkActionBar">
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style
name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<!-- Support library compatibility -->
<item name="background">#drawable/actionbar_background</item>
</style>
</resources>
manifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomActionBarTheme" >
...
I made sure i have actionbar_background.png(which is an square image with a color basically) in the correct folders. however. when i run the up i still see the old action bar like nothing changed.

Categories

Resources