How can I change the style of DatePicker? - android

I'm trying to change my datepicker styles, but I don't know the properties.
I'm using the following librarie: https://github.com/mmazzarolo/react-native-modal-datetime-picker
I’ve managed to change the colors, but I would like to change more things, such as the border radius.
I changed the styles.xml file this way:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:datePickerDialogTheme">#style/Dialog.Theme</item>
</style>
<style name="Dialog.Theme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#0981bf</item>
<item name="android:textColorPrimary">#7a7a7a</item>
</style>
</resources>
I've searching information about this, but I have not found anything....
Is it possible to change the border radius? Is there information about the items I can change?

Related

When trying to use the material theme on Android, my title bar is not using the primary colour

From my research, it appears that when using the material theme on Android the title bar should take on the primary color but for me, it stays black. I know the theme itself is working as things did change to black when I first applied the default(dark) theme. I have this set in the styles.xml file:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
</style>
</resources>
The colors referenced from colors.xml are working as they show up on the s the de in android studio.
I have tried looking for a way to manually change the title bar but I have only found ways to do it programatically and not through layout files. I have attached a pic of what the title bar currently looks like and what i would like it to look like below:
Current title bar
What I want it to look like
Change it to
<style name="AppTheme" parent="android:Theme.Material">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
</style>

Override Android background in custom style for one theme but not another

I'm using two themes for my Android application, AppTheme and AppThemeDark. I've set up a custom button style for each in the theme definitions:
<!-- Theme definitions -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="android:buttonStyle">#style/ButtonStyle</item>
...
</style>
<style name="AppThemeDark" parent="Theme.AppCompat.DayNight.NoActionBar">
...
<item name="android:buttonStyle">#style/ButtonStyleDark</item>
...
</style>
<!-- Button styles -->
<style name="ButtonStyle" parent="#style/Widget.AppCompat.Button">
<item name="android:ellipsize">end</item>
<item name="android:maxLines">2</item>
</style>
<style name="ButtonStyleDark" parent="ButtonStyle">
<item name="android:background">#drawable/gray_button_bg</item>
</style>
Note that my AppTheme button, ButtonStyle, doesn't override the background of Widget.AppCompat.Button, but AppThemeDark's button style inherits ButtonStyle and it changes the background.
Now, I would like to extend that buttonStyle with a new custom style for special buttons, e.g. PrimaryButton. In the AppTheme case, I do not want to change the background of the button. In the AppThemeDark case, i do want to change the background of the button.
I would like to define PrimaryButton and have it either inherit the background (in the case of AppTheme) or use a new background (AppThemeDark). Something like this:
<style name="PrimaryButton">
<item name="android:background">?attr/drawablePrimaryButtonBackground</item>
</style>
But as far as I can tell, there's no way to define an attribute in AppThemeDark as a new drawable and AppTheme as "inherit from parent". Setting to transparent obviously makes the button background in AppTheme transparent.
Is my only option to figure out what drawable is being used for a background in Widget.AppCompat.Button and define it locally?
To answer my own question...
You can dig up the private Android resource and use a local copy to retain the background. That locks you into one specific Android version of the drawable though (unless you copy multiple versions over).
You can set whole styles as attributes if the styles between your two themes are different enough to warrant it:
attrs.xml:
<attr name="stylePrimaryButton" format="reference" />
styles.xml:
<!-- Theme definitions -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="stylePrimaryButton">#style/PrimaryButton</item>
...
</style>
<style name="AppThemeDark" parent="Theme.AppCompat.DayNight.NoActionBar">
...
<item name="stylePrimaryButton">#style/PrimaryButtonDark</item>
...
</style>
<!-- Primary button styles -->
<style name="PrimaryButton">
<!-- no need to override anything -->
</style>
<style name="PrimaryButtonDark">
<item name="android:background">#drawable/dark_background</item>
</style>
layout.xml:
<Button style="?attr/stylePrimaryButton"
...

How to change highlighted EditText color in Android?

I am totally new to Android and ran into the following: while using the Material Light Theme my EditText turns a shade of pink upon selection.
I searched around how to change it and found the following telling me to change the android:textColorHighlight to my preferred color:
How to set color of selection in EditText in my custom theme? (android)
Sadly this doesn't seem to work for me.
This is my styles.xml:
<!-- res/values/styles.xml -->
<resources>
<!- theme inherits from the material theme -->
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/lightText</item>
<item name="android:navigationBarColor">#color/navigationBarColor</item>
<item name="android:textColorHighlight">#color/textColorHighlight</item>
<!-- theme customizations -->
</style>
</resources>
Any pointers as to what I'm doing wrong?
Thanks!
Found it:
EditText uses the themecolor defined as: android:colorAccent
So:
<item name="android:colorAccent">#color/colorAccent</item>
Hope this helps anyone in the future
Go to the settings:
And here's the result:

Custom button style shown in GUI preview, but not in actual app

styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:buttonStyle">#style/button_style</item>
</style>
<style name="button_style" parent="#android:style/Widget.Button">
<item name="android:background">#drawable/simple_button</item>
</style>
</resources>
And I've verified that simple_button works - if I manually assign it to a button's background, it shows up in the app.
Do you have only one styles.xml file? Check this.
Generally has a number of styles.xml files. (ex> values/styles.xml, values-v21/styles.xml, etc...) and Check your device information.
Try using
<item name="buttonStyle">#style/button_style</item>
instead of:
<item name="android:buttonStyle">#style/button_style</item>

android: How to change ListPreference title colour?

I would like to change the title and line color of my ListPreference from blue to pink, to match the line of my action bar.
Any ideas? Thanks in advance!
I've been looking through Android's themes.xml and styles.xml looking at things like dialogPreferenceStyle, but haven't figured it out yet.
Had the same problem today.
Old thread, but I found this: and it works perfectly.
Simply modify your styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<!-- Add this -->
<item name="android:dialogTheme">#style/DialogStyle</item>
<item name="android:alertDialogTheme">#style/DialogStyle</item>
</style>
<!-- Customize your color here -->
<style name="DialogStyle" parent="android:Theme.Material.Dialog">
<item name="android:colorAccent">#color/colorAccent</item>
</style>
Ended up creating a custom ListPreference widget, following this answer.
I hoped to be able to simply change the style without having to implement a custom widget, but I haven't figured that out yet.

Categories

Resources