I've been overriding the default button style in my app like this:
<style name="ButtonStyle" parent="Base.Widget.AppCompat.Button">
<item name="android:textAllCaps">false</item>
<item name="android:textSize">18sp</item>
<item name="android:textColor">#color/primaryTextContrast</item>
<item name="android:background">#drawable/button</item>
</style>
That worked fine until Nougat, but with Nougat there's been a change (a bug fix I think) such that this style also applies to buttons in dialogs, while in previous versions it did not. This has the effect of giving the dialog buttons white text on a white background.
In case it's relevant, button is a 9 patch in drawable and is overridden in drawable-v21:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorControlHighlight">
<item android:drawable="?attr/colorPrimary"/>
</ripple>
The primary color is dark, and primaryTextContrast is white. Dialogs do not get dark buttons in Nougat for some reason - they seem to pick up the text color but not the background. So I need to either let the dialog buttons do their default thing, or make the buttons fully inherit the style with a dark background and white text.
#nasch, Dialog buttons use button bar style. In this scenario, you could do something like
<style name="buttonBarButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
<item name="android:textColor">#color/colorPrimary</item>
</style>
In your main style definition, you then define
<style name="MyCustomTheme" parent="Theme.AppCompat">
<item name="buttonBarButtonStyle">#style/buttonBarButtonStyle</item>
...
Hope this helps.
Related
wallpicker app
I was actually trying to make an overlay theme that override my settings and other apps, I've somehow successfully make it transparent and change the font color but one thing i couldn't change is the header of it, in the image you'll see a "Settings" which isn't white color, that's my current problem, it also happened on other header apps just like "wallpaper picker app" and more apps
Already tried:
<item name="android:colorBackground">#android:color/primary_dark_device_default_settings</item>
<item name="android:windowBackground">#40000000</item>
<item name="android:windowShowWallpaper">true</item>
<item name="android:textColor">#ffffff</item>
adding a textColor but it didn't change the header text color or was it called an action bar?
also textColorPrimary doesn't do anything at all? and im on api 33
https://i.stack.imgur.com/3jsNN.jpg
https://i.stack.imgur.com/0Jsly.png
Try this.. In your original theme
<style name="Theme.MyApplication" parent="Theme.MaterialComponent.DayNight.NoActionBar">
<item name="toolbarStyle">#style/CustomToolbar</item>
</style>
your theme settings as follow:
<style name="CustomToolbar" parent="#style/Widget.MaterialComponents.Toolbar">
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
</style>
For some reason the menu that comes up on long click (for copy/paste/cut/etc...) in my EditText have white text color on a white background so it's unreadable.
I searched quite a lot on this forum but haven't found answer that would have worked so far, I have also tried adding a custom popup style for the base theme as well as for the EditText style with colorAccent, color and textColor changed, like this:
<style name="Base.AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Tried all 3 separately -->
<item name="android:popupMenuStyle">#style/CustomPopup</item>
<item name="popupMenuStyle">#style/CustomPopup</item>
<item name="popupTheme">#style/CustomPopup</item>
</style>
<style name="Style.Input.EditText" parent="Widget.AppCompat.EditText">
<!-- Tried all 3 separately -->
<item name="android:popupMenuStyle">#style/CustomPopup</item>
<item name="popupMenuStyle">#style/CustomPopup</item>
<item name="popupTheme">#style/CustomPopup</item>
</style>
<style name="CustomPopup" parent="Widget.AppCompat.Light.PopupMenu">
<item name="android:colorAccent">#000000</item>
<item name="android:color">#000000</item>
<item name="android:textColor">#000000</item>
</style>
Unfortunately it did not work.
Does anyone know of a way to customise this menu, the text color in particular?
Check the theme style
<item name="android:background">#FFFFFF</item>
It's highly likely that you have it set to WHITE and the text is already being set to WHITE. I would comment out this line where you're setting the background color and see if you can't figure it out from there. This was my issue.
I'm modifying downloads (for 4.3 Jellybean) and I can't change the colour of the text on the bottom button from black to white. Is it possible to change the text colour without giving the button its own style by adding an item in the app theme? Here is my Styles.xml:
<style name="DownloadListTheme" parent="#android:style/Theme.DeviceDefault.Light.DialogWhenLarge">
<item name="android:textAlignment">viewStart</item>
<item name="android:layoutDirection">locale</item>
<item name="android:actionBarStyle">#android:style/Widget.DeviceDefault.Light.ActionBar.Solid.Inverse</item>
<item name="com.sonyericsson.uxp:extendedLookAndFeel">true</item>
<item name="android:textColor">#android:color/white</item>
</style>
Yes, you can accomplish this pretty easily, just override your theme in styles.xml like this:
<style name="MyButtonStyle"
parent="#android:style/Theme.DeviceDefault.Light.DialogWhenLarge">
<item name="android:textColor">#android:color/white</item>
</style>
For more information, see the documentation.
I have my style defined as follows:
<style name="actionBarTheme" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/button_style</item>
<item name="android:titleTextStyle">#style/actionBarTitleText</item>
</style>
And the actionBar is actually of the color defined in button_style (correctly working in other parts of the code). The problem is that the items are not working correctly (the background color is too light).
Any idea on how to solve this? Thanks
EDIT:
In the picture there is the touch-feedback that I have now. The button_style has another touch effect (a darker one) since this is almost invisible.
You can have this affect with actionButtonStyle
<style name="appTheme">
<item name="android:actionBarStyle">#style/actionBarTheme</item>
<item name="android:actionButtonStyle">#style/actionButtonTheme</item>
</style>
and then place your button style as the background of that.
<style name="actionButtonTheme">
<item name="android:background">#drawable/button_style</item>
</style>
You will still need to set the background of your action bar but this only needs to be a colour or drawable image as that is all that will actually be used.
Ok, this is driving me bonkers. To skin my app, I set the following in my theme:
<item name="android:textColor">#FFFFFF</item>
All the text in the app turns white, unless I manually override it in the layout xmls. Great, yay, easy peasy. EXCEPT that the text in my menu options for context menus (off of lists and such) have also decided to become white.
This is not so great, since it is hard to read white on white. I have tried a variety of solutions, including searching for how to change the text color of a context menu (no dice)and creating a textAppearance item in my theme. The last solution didn't change all the textfields in my app, which was frustrating.
So, any suggestions? Hopefully my dilema is clear.
In your styles.xml try overriding the textViewStyle instead of just ALL textColor attributes:
<style name="Theme.Blundell.Light" parent="#android:style/Theme.NoTitleBar">
<item name="android:windowBackground">#drawable/background_light</item>
<item name="android:textViewStyle">#style/Widget.TextView.Black</item>
</style>
<style name="Widget.TextView.Black" parent="#android:style/Widget.TextView">
<item name="android:textColor">#000000</item>
</style>
You could even take it one further and just override the color for a certain view, like buttons:
<style name="Widget.Holo.Button" parent="#android:style/Widget.Holo.Button">
<item name="android:textColor">#FFFFFF</item>
</style>
<style name="Theme.Blundell" parent="#android:style/Theme.Holo.NoActionBar">
<item name="android:colorBackground">#android:color/transparent</item>
<item name="android:buttonStyle">#style/Widget.Holo.Button</item>
</style>
If your inspired to do any more theming check out the Android source it's the best place to realise what you can and can't do!:
https://github.com/android/platform_frameworks_base/tree/master/core/res/res/values
Use this:
parent="Theme.AppCompat.Light.DarkActionBar"