This my style page:
<resources>
<color name="for_custom">#ff4db0e8</color>
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">#color/for_custom</item>
<item name="android:actionBarTheme">#color/for_custom</item>
<item name="android:displayOptions">homeAsUp</item>
</style>
</resources>
And this is my manifest:
<application android:label="#string/app_name" android:icon="#mipmap/ic_launcher" android:theme="#style/CustomTheme">
action bar does not show After applying theme.Why?
What is my mistake?
If you are on Lollypop+ the default Theme is Material, which does not show the ActionBar. This is because the Material Design spec remarks the Toolbar view as the new way to keep the buttons. If you want the old style, use Theme.Holo.Light instead of just Theme.Light
Related
I want to make a transparent status bar in my application in Android 4.4.
How do I do that?
I tired:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/skipPrimary</item>
<item name="colorPrimaryDark">#color/skipPrimary</item>
<item name="colorAccent">#color/skipPrimary</item>
</style>
and in the manifest:
<application
android:name=".App"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme" >
and in the activity:
<activity
android:name=".activities.StartActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize"
android:screenOrientation="portrait"
android:theme="#style/AppTheme"
android:windowSoftInputMode="adjustResize|stateHidden" />
This one will throw exception on Lollipop devices. primColor must be opaque.
<item name="primColor">#android:color/transparent</item>
Style your actionbar using style.xml
<style name="ThemeActionBar"
parent="Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:background">#null</item>
<!-- Support library compatibility -->
<item name="background">#null</item>
</style>
Include you theme..
<item name="android:actionBarStyle">#style/ThemeActionBar</item>
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/ThemeActionBar</item>
<item name="windowActionBarOverlay">true</item>
What you can also do is set the status bar a darker shade of your background or even the same color by setting it in your activity.
You can set the status bar color in your activity with the following code getWindow().setStatusBarColor(getResources().getColor(R.color.your_color));.
If you want to use a darker shade of your color you can do it by changing your color's HSB. For a more detailed way of doing that you can read this post: Android change status bar color by converting existing color's HSB
Hey I'm trying to change the background of my action bar but I'm not quiet sure I understand the structure of the style files. So basically I have style.xml which is to pass on some elements a desired style. Then I've Theme.xml which is to have a group of styles in it, correct ? How do you link the two in other words how do I tell the theme I want the specified style in it ? I can't manage to change the background of the action bar so here is my code:
style.xml:
<!-- Base application theme. -->
<style name="MyActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:colorBackground">#color/color_lightBlue</item>
</style>
</resources>
theme.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyCustomTheme" parent="Theme.AppCompat.Light">
</style>
</resources>
and wtf is v11/style ?
Whether you put the attributes in styles.xml or theme.xml, they have the same effect finally if you apply the theme to your app or activity. In your AndroidManifest.xml, in order to let the theme have the effect you want, you should apply your customized theme like following to your app.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
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?
Android action bar tabs are left-aligned by default, I want to align it the center of the action bar. Is there any way we can make it center?
I was able to center-align the actionbar by customizing my application theme
In my AndroidManifest.xml, I added a android:theme property:
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#style/CustomActionBarTheme">
...
I then added a new themes.xml file to my project, and added :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarTabBarStyle">#style/MyActionBarTabBar</item>
</style>
<style name="MyActionBarTabBar">
<item name="android:gravity">center</item>
</style>
</resources>
The tabs should now be center-aligned.
EDIT:
It works only if your actionbar is displayed on 2 lines (in portrait)
You can use the ViewPagerIndicator plugin to customize your tabs.
Hope it helps!
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>