There is no Theme.Light.Dialog to use with the rest of my project that is using Theme.Light.
How can I change Theme.Dialog to look like a Theme.Light version of Dialog.
I know that I must overwrite sections of Theme.Dialog in styles.xml as below. What items should I overwrite with which values?
<style name="dialog_light" parent="#android:style/Theme.Dialog">
<item name="android:???????"></item>
<item name="android:???????"></item>
</style>
I could just make the background that light white grey, but the buttons, spinners etc are also different on the light theme to look better on the light background.
EDIT
Looks like I got it working.
<color name="black">#FF000000</color>
<color name="whitegrey">#FFF2F2F2</color>
<style name="dialog_light" parent="#android:style/Theme.Dialog">
<item name="#android:windowBackground">#color/whitegrey</item>
<item name="#android:textColor">#color/black</item>
</style>
Looks like I got it working.
<color name="black">#FF000000</color>
<color name="whitegrey">#FFF2F2F2</color>
<style name="dialog_light" parent="#android:style/Theme.Dialog">
<item name="#android:windowBackground">#color/whitegrey</item>
<item name="#android:textColor">#color/black</item>
</style>
Further to the above, to avoid making up colors, I did this:
<!-- Makes a "light" equivalent of Theme.Dialog -->
<style name="dialog_light" parent="#android:style/Theme.Dialog">
<item name="#android:background">#android:color/background_light</item>
<item name="#android:textColor">#android:color/primary_text_light</item>
</style>
This is good, thanks!
I just changed it a bit: when I run what you suggested, the entire screen is painted with the back color and the dialog does not look as it should (with the previous activity dimmed).
So instead of using
#android:windowBackground
just use
#android:background
Related
I worked myself thru the AndroidFundamtentals Tutorial 09.2 (App Settings) but I couldn't find a working solution for my problem.
I want to change the style (backgroundcolor) of the Settings-Fragment in my app.
That's what I have coded in the styles.xml so far:
<style name="AppThemeWithActionBar" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="colorPrimary">#color/cr_blue_dark2</item>
<item name="colorPrimaryDark">#color/cr_blue_dark</item>
<item name="colorAccent">#color/cr_green</item>
<!-- more styles-->
<item name="preferenceTheme">#style/AppTheme.SettingsScreen</item>
</style>
<style name="AppTheme.SettingsScreen" parent="PreferenceThemeOverlay">
<item name="backgroundColor">#color/cr_black</item>
<item name="background">#color/cr_black</item> <!--one of these should make the background black-->
</style>
This code does not change the background color of the Settings fragment.
If you need more code just write an comment. :)
I just found the solution / mistake.
The parent of the style AppThemeWithActionBar is wrong.
It changes the background to light.
Change the title of the style like this:
<style name="AppThemeWithActionBar" parent="Theme.MaterialComponents">
Also change the theme of the activity in the Manifest.xml file.
As the title says, I want to change the color of DatePicker from black to white but I did not sorted this out after trying multiple times. I've seen Nativescript's documentation regarding this but I might not understand it correctly how to do it. Also tried this example for Android API21+ from https://docs.nativescript.org/ui/components/date-picker , but nothing happens:
<!-- DatePicker in calendar mode -->
<style name="AppTheme" parent="AppThemeBase">
<item name="android:datePickerStyle">#style/CalendarDatePicker</item>
</style>
<style name="CalendarDatePicker" parent="android:Widget.Material.Light.DatePicker">
<item name="android:datePickerMode">calendar</item>
<item name="colorPrimary">#color/ns_blue</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
</style>
You need to add it them into colors.xml:
App_Resources/Android/src/main/res/values-v21/colors.xml
<color name="ns_blue">#ff7800</color>
<color name="ns_primaryDark">#17143d</color>
<color name="ns_accent">#8095ac</color>
according to this solution:
Nativescript Datepicker change text color
I have a menu in my android activity (I am working with Xamarin.Android) and that contains several items, like this one:
<item android:id="#+id/menuitem1"
android:icon="#drawable/ic_action_share"
android:showAsAction="ifRoom" />
I can customize the whole ActionBar. But I want to customize just one item in the actionbar. Like the following Icon in the middle (the blue one):
How can I achive this? Thanks in advance.
First thing that we need to do is set up the basic colour values in res/values/colors.xml that we used in Jeff’s Generator tool:
<color name="sa_green">#14a804</color>
<color name="stacked_green">#118504</color>
<color name="accent_green">#97e08f</color>
create a new style, which we’ll call “ActionBar” in res/values/styles.xml:
<style name="ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/sa_green</item>
<item name="android:backgroundStacked">#color/stacked_green</item>
<item name="android:backgroundSplit">#color/sa_green</item>
</style>
Now it must set this style on the ActionBar by adding an actionBarStyle to the theme in res/values/styles.xml:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar</item>
</style>
.
.
.
try this ...
I am trying to set the default background color of all my Activities to white, but it doesn't seem to work properly on Jelly Bean (comes out cyan). I'm thinking it might be something with the V4 appcompat FragmentActivity (as standard Activities seem to be fine).
What I have done in styles.xml is this:
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:windowBackground">#android:color/white</item>
<item name="android:colorBackgroundCacheHint">#android:color/white</item>
<item name="android:colorBackground">#android:color/white</item>
</style>
In your resource folder under values create a new XML file called color.xml if it does not already exist. Then add a new colour to the colour xml file.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
</resources>
remove "android:" in your xml and it should turn to white.
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:windowBackground">#color/white</item>
<item name="android:colorBackgroundCacheHint">#color/white</item>
<item name="android:colorBackground">#color/white</item>
</style>
I'm using Theme.Dialog on one of my activities. I'm using setTitle(mMyTitle) to set the title. I would also like to set the textAppearance. How would I go about this?
I'm not sure if I can make my own title layout for this, since I'm already using Theme.Dialog.
Create a new style and extend Theme.Dialog then override what you want to change. Example:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyActivityDialogTheme" parent="#android:style/Theme.Dialog">
<item name="android:windowTitleStyle">#style/MyTitleStyle</item>
</style>
<style name="MyTitleStyle" parent="#android:style/DialogWindowTitle">
<item name="android:textAppearance">#style/MyTextApperance</item>
</style>
<style name="MyTextApperance" parent="#android:style/TextAppearance.DialogWindowTitle">
<item name="android:textColor">#ffff0000</item>
<item name="android:textSize">36sp</item>
</style>
</resources>
Anything you don't specify will use the Dialog defaults. I've only specified the colour and font size of the textApperance in this example.
Now just use MyActivityDialogTheme (or whatever you call your style) as the theme for your activity instead of Theme.Dialog.
Check this out first, but I believe what you're looking for is about 3/4 the way down when it discusses tweaking a built-in resource by referencing it as a parent for your custom theme. As such:
<color name="custom_theme_color">#b0b0ff</color>
<style name="CustomTheme" parent="android:Theme.Dialog">
<item name="android:windowBackground">#color/custom_theme_color</item>
<item name="android:colorBackground">#color/custom_theme_color</item>
</style>
Hope it's what you're looking for.