In my styles.xml file I have a style to remove the title bar and other styles to change my tabwidget's font size:
<?xml version="1.0" encoding="utf-8"?>
<style name="RemoveTitleBar" parent="android:Theme">
<item name="android:style/Theme.Black.NoTitleBar.Fullscreen">true</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="CustomTheme" parent="android:style/Theme">
<item name="android:tabWidgetStyle">#style/CustomTabWidget</item>
</style>
<style name="CustomTabWidget" parent="android:style/Widget.TabWidget">
<item name="android:textAppearance">#style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText" parent="android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">12sp</item>
<item name="android:textStyle">bold</item>
</style>
In my AndroidManifest.xml file I set the RemoveTitleBar style to the application which works fine:
<application
android:icon="#drawable/ic_launcher_test_icon"
android:label="#string/app_name"
android:theme="#style/RemoveTitleBar"
....
However when I apply the CustomTheme style to my activity with tabs, I get the title bar back. But if I remove the line it works fine.
<activity android:name=".TabActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/CustomTheme"> </activity>
Am I going about this the wrong way or do I have to change something in my styles.xml file? Thanks for you time.
You are extending CustomTheme with "android:style/Theme":
<style name="CustomTheme" parent="android:style/Theme">
<item name="android:tabWidgetStyle">#style/CustomTabWidget</item>
</style>
and the titleBar is available in in this you aren't removing the titleBar, you will again need to remove the titleBar like this:
<style name="CustomTheme" parent="android:style/Theme">
<item name="android:tabWidgetStyle">#style/CustomTabWidget</item>
<item name="android:style/Theme.Black.NoTitleBar.Fullscreen">true</item>
</style>
Related
I'm trying to change the background color of my Actionbar, but after referencing the several other questions on this site I still can't get their solutions to work.
Styles.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">#style/ActionBar</item>
<item name="android:windowActionBar">true</item>
</style>
<style name="ActionBar" parent="Widget.AppCompat.ActionBar.Solid">
<item name="background">#color/light_blue_menu_bar</item>
</style>
</resources>
colors.xml
<resources>
...
<color name="blue_semi_transparent_pressed">#80738ffe</color>
<color name="light_blue_menu_bar">#87CEFA</color>
</resources>
manifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
However the ActionBar doesn't appear in of my views. What am I missing?
EDIT
The solution was to add to styles.xml
<item name="android:windowActionBar">true</item>
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBarStyle</item>
<item name="actionBarStyle">#style/ActionBarStyle</item>
<item name="android:windowActionBar">true</item>
</style>
<style name="ActionBarStyle" parent="Widget.AppCompat.ActionBar">
<item name="background">#color/blue</item>
<item name="android:background">#color/blue</item>
</style>
You can use this,
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#Color_Code")));
Maybe you should edit styles.xml at values-v14 folder.Because your min version is 19.
I wanna change my Apps Titlebar color and tried it in this way:
Part of the manifest file:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/Theme.MyTitleBar" ></application>
The style block part of the file styles.xml:
<style name="Theme.MyTitleBar" parent="android:Theme">
<item name="android:colorBackground">#FFFFFF</item>
<item name="android:background">#FFFFFF</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">16sp</item>
</style>
But only the text color and attributes changes correct. Any guest what I did wrong?
EDIT: I added the part for the ActionBar (sorry I put only for Dialogs at first)
You can follow this, it will allow you to change moreover other attributes that just the title bar:
Just call your custom theme in the manifest file:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
Then create these 2 styles in your styles.xml. The first one defines the theme, the second one, one of the styles to apply on the theme:
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:colorBackground">#FFFFFF</item>
<item name="android:background">#FFFFFF</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">16sp</item>
</style>
NOTE: In this example, I customize the theme Holo Light as you can see with this: android:style/Widget.Holo.Light.ActionBar.
Add This style.xml File in your project according to your requirment...
<item name="android:actionBarStyle">#style/myActionBar</item>
</style>
<style name="myActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:titleTextStyle">#style/myActionBar.titleTextStyle</item>
</style>
<style name="myActionBar.titleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title.Inverse">
<item name="android:textColor">#color/darkgrey</item>
</style>
<style name="myActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#e6ebc3</item>
</style>
I want to add a style from styles.xml
<style name="BlueActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#color/blue</item>
<item name="android:textColor">#FFFFFF</item>
</style>
to my Actionbar but just on the Activity BlueActivity (which is still blank). How to do that? I'm stuck :'(
edit:
Why does adding
android:actionBarStyle="#style/BlueActionBar"
to BlueActivity in the Manifest not work?
themes.xml:
<style name="Theme.Project.Activity1" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/Widget.Project.Activity1.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.Project.Activity1.ActionBar</item>
</style>
AndroidManifest.xml:
<activity android:name="com.example.Activity1"
android:theme="#style/Theme.Project.Activity1"
/>
<activity android:name=".activity.MyHomePage" android:theme="#style/AppTheme.Light" android:label="New Tasks"/>
I have that Activity in my AndroidManifest.xml file. How do I set style on that android:label. I would like to set textsize and textcolor.
<style name="AppTheme.Light" parent="#android:style/Theme.Holo.Light">
<item name="android:windowBackground">#drawable/background</item>
<item name="android:actionBarStyle">#style/ActionBarTextSize</item>
<item name="android:windowTitleSize">14pt</item>
</style>
OR
<style name="ActionBarTextSize" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:textSize">14pt</item>
</style>
Are you talking about creating a custom window title style? If so, check this out: http://www.londatiga.net/it/how-to-create-custom-window-title-in-android/
I created a custom title bar for my application but I am having some problems implementing it. I want to change the color and the appearance for the text and title bar
The layout of the styles.xml is as below:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme">
<item name="android:tabWidgetStyle">#style/LightTabWidget</item>
</style>
<style name="MyWindowTitleBackground" parent="#android:style/WindowTitleBackground">
<item name="android:background">#android:drawable/title_bar</item>
</style>
<style name="MyWindowTitle" parent="#android:style/WindowTitle">
<item name="android:singleLine">true</item>
<item name="android:windowTitleSize">40dip</item>
<item name="android:textAppearance">#style/MyTextAppearance</item>
<item name="android:shadowColor">#BB000000</item>
<item name="android:shadowRadius">2.75</item>
</style>
<style name="MyTextAppearance" parent="#android:style/TextAppearance.WindowTitle">
<item name="android:textColor">#3A6629</item>
<item name="android:textSize">14sp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="LightTabWidget" parent="#android:style/Widget.TabWidget">
<item name="android:textSize">20px</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#FF5721</item>
</style>
</resources>
And I have added that theme in the manifest file as follows:
<application android:icon="#drawable/icon" android:label="#string/app_name" android:theme="#android:style/Theme.Light">
<activity android:name="LAFoodBankAboutUs" android:label="#string/app_name" android:theme="#style/MyTheme">
What do I have to do to show the custom title bar?
By now (after some years), the Toolbar is available. It features a lot of customization possibilities and is also available via the Support Library