Android Custom Theming in ActionBar/Tabs - android

I have the theme Holo.Light.DarkActionBar
The tabs are now set to white background, light gray text--very unreadable. I simply want to change the text to something much, much darker.
I have searched the styles to see if I can override but all I can do is change the background, not the text.
Can I do this in the styles.xml or do I have to do this programmaticly?

If you're referring to the ActionBar's tab see if this changes the color:
<!-- The theme for the activity -->
<style name="TabSpecialTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="#android:attr/actionBarTabTextStyle">#style/TabStyle</item>
</style>
<!-- Modify the text color -->
<style name="TabStyle" parent="android:Widget.Holo.Light.ActionBar.TabText.Inverse">
<item name="android:textColor">#F70000</item>
</style>
Of course don't forget to set the theme for the activity to #style/TabSpecialTheme in the manifest.

Related

Change Xamarin Forms Android Navigation Page Colours (buttons & back)

I am trying to change the appearance of the navigation page in my Xamarin Forms application. I want a blue bar with all text being white. I have been able to set the NavigationPage's properties, but I cannot set the bar button items or the back button's colour. Here are 2 screenshots illustrating what my app looks like currently:
The black colour looks awful, this NEEDs to be white. Now I had a look at how I can change these colours however nothing seemed to work.
I have currently tried the solutions presented in these posts:
Change navigation bar back button color in xamarin android
Change action bar colors
Change navigation bar back button color in xamarin android
This half works, it sets the toolbar text ALL to white... but then my app's theme is dark, all of the colours change and conflicts with the implemented design.
This is getting the point where it is ridiculous, I implemented this on iOS in under 5 minutes and i've spent the best part of a day trying to make some text white...
How can I set just the text on the navigation bar to white, an example in iOS (without code infront of me) is self.navigationBar.tintColour =' White', which would apply white over any content on the nav bar.. Exactly what i want!
Thanks & here is my styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#FF4081</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">#style/AppCompatDialogStyle</item>
<item name="android:actionBarPopupTheme">#style/CustomActionBarPopupTheme</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#cbff34</item>
</style>
<style name="CustomActionBarPopupTheme" parent="android:ThemeOverlay.Material.Light">
<item name="android:colorBackground">#cbff34</item>
<item name="android:textColor">#cbff34</item>
</style>
</resources>
You can add a style to your styles.xml,
<style name="ToolbarStyle" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize color of navigation drawer icon and back arrow -->
<item name="colorControlNormal">#ffffff</item>
</style>
and add this as theme to your toolbar in toolbar layout.axml(in android project under layout folder) , check below
android:theme="#style/ToolbarStyle"

How to get orange button text, white tab indicators and black titles with Appcompat

On android 7 (nexus phone) the title in my context menu appears white. I would expect it to be black as it is on all other devices I tested. The rest of the app looks good.
Update:
I figured out that the colorAccent is the culprit (AppCompat styles various things based on that). I set it to white in a child theme because the tabBar needs to have white tab indicators.
So now the issues is that I need white tab indicators in the actionbar, black titles in dialogs and context menus and Orange text on buttons styled with the Button.Borderless.Colored style. All of these seem to be controlled with colorAccent. I can make a seperate style for the buttons. But the styles of the dialogs and tab indicators are still conflicting. For legacy reasons I cannot use the new toolbar with a tablayout (That one is stylable) but have to use the Actionbar. Any ideas?
White title in context menu screenshot:
Thanks in advance!
Theme:
<resources>
<!-- default theme -->
<style name="Theme.MyApp" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Remove actionbar -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!-- Basic coloring -->
<item name="colorPrimary">#color/MyAppOrange</item>
<item name="colorPrimaryDark">#color/MyAppOrangeDark</item>
<item name="colorAccent">#color/MyAppOrangeDark</item>
<!-- AppCompat dialog themes -->
<item name="dialogTheme">#style/Theme.MyApp.Dialog</item>
<item name="alertDialogTheme">#style/Theme.MyApp.Dialog.Alert</item>
///// Tried this with a custom style but that just f*cked up my tabs...
<item name="actionBarTabStyle">#style/CustomActionBarTabs</item>
</style>
<!-- Alert and dialog styles -->
<style name="Theme.MyApp.Dialog" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">#color/MyAppOrange</item>
<item name="colorPrimaryDark">#color/MyAppOrangeDark</item>
<item name="colorAccent">#color/MyAppOrangeDark</item>
</style>
<style name="Theme.MyApp.Dialog.Alert" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorPrimary">#color/MyAppOrange</item>
<item name="colorPrimaryDark">#color/MyAppOrangeDark</item>
<item name="colorAccent">#color/MyAppOrangeDark</item>
</style>
</resources>
Djangow, you need to define a new style that with the text color as the specific color you want and then set that style in the app theme you want to use. See this link for the exact coding needed.
UPDATE: Djangow, I apologize. I looked into it and found that you have to add this line <item name="android:actionMenuTextColor">#color/your_color</item> to the main App theme. I found the answer here. Hope that helps

Custom Theme Android

In the app that I am making I want to theme some of my display widgets (dialog, actionbar, etc) but keep Theme.Holo as a parent for things I don't want to theme (buttons, spinners, etc)
So in my manifest I changed:
android:theme="#android:style/Theme.Holo"
to
android:theme="#style/CustomTheme"
and then in themes.xml I made my CustomTheme and overrode my actionbar and dialog:
<!-- Custom Holo (Dark) Theme -->
<style name="CustomTheme" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/CarCastActionBar</item>
<item name="android:alertDialogTheme">#style/CustomDialogTheme</item>
<item name="android:dialogTheme">#style/CustomDialogTheme</item>
<item name="android:alertDialogStyle">#style/CustomDialogTheme</item>
</style>
only now my spinners have gone back to an ugly white instead of the flat transparent look.
Why is it doing this? I can attach pictures if it would help
The default Holo theme, which you are using expects a dark background. So the ui elements will have a white translucent color. Trying using the Holo Light theme to have darker ui elements.
android:Theme.Holo.Light

My action bar title is taking the wrong color from theme

I'm attempting to modify the theme for my application. I've been able to successfully set the background color for my app, and the background color for my action bar.
Unfortunately, the background color of the items WITHIN the action bar are taking the background color of the app, not the bg color of the action bar.
Here's my code from styles.xml
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:background">#ff0000</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#fefefe</item>
</style>
and here's a screenshot of what's happening.
Hoping I'm missing something stupid here...
Thanks!
I'm pretty sure your theme background is being applied to everything. Instead, you only want the activity's background to be that color. So instead of setting the background color in the theme, you should set it for the activity. If you have many activities that will use this background color, then create a style for your activities and apply it to each one.
Try using:
<item name="android:windowBackground">#color/your_color</item>
<item name="android:colorBackground">#color/your_color</item>
Worked for me.

Changing the action bar overflow icon to the dark version

In my application I am using my own theme based on the Theme.Holo.Light
However I have customised the actionBarStyle, setting the background drawable to a blue gradient to fit with my app's style.
However, with the Halo light theme, the action bar text is dark, & the default icons, such as the Up Nav arrow and the menu icon are dark, these don't go on my blue gradient.
As you can see from my XML below, I have managed to correct the title text colour but I can't find the attribute I need to override for the icons.
How can I change tell the theme to effectively use the icons on the ActionBar from Theme.Halo
instead of those Theme.Halo.Light but making the rest of my application remain using Theme.Halo.Light
Here's my current XML
<style name="MyLightTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/blue_gradient_light</item>
<item name="android:titleTextStyle">#style/Theme.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.ActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/solid_white</item>
</style>
Thanks for your help
Use Theme.Holo.Light.DarkActionBar as your base if you want to do this. It will take care of these details.

Categories

Resources