I'm developing an android app where i want to have a night theme also. I don't know how to proceed here. I want an option to be set in settings that automatically set the day/night theme. And theme should be set according to the time same as in google maps.
How can i do this?
You just need to add the timings at which the night theme would be changed. Checkout the this AppCompat v23.2 — DayNight
Related
I'm building a material design playground that can switch between the available pre-defined themes that can apply the color, typography and shapes to all the material design components throughout the app.
Right now, the user can choose available themes from the PreferenceScreen:
I got a NEW requirement that should allow the user to enter a value (eg. set color of colorPrimary). From the input, I would like to modify the Theme directly so that it could apply the change in the app.
How can I do this? I'm thinking of giving an option to the user something like below:
Here's a link to my sample material design playground app:
https://github.com/ciscosoriano/material-design-dynamic-theming
Seems like you need something like this android-how-to-change-application-theme-programmatically
link: android-how-to-change-application-theme-programmatically
This should be easy and there are lot of tutorials out there, don't forget to checkout
Basically what you need to do is:
apply statically defined theme(in res/values) as usual before activity is launched.
Now get the user input when activity is launched
Then get the current theme attributes using appropriate api and recolourize the ui controls dynamically in the program.
restart activity with the updated theme.
Some more link: Set theme color dynamically
You should be comfortable handling the activity lifecycle to view the updated theme when set.
I am working on an Android project where I need to support switching between Dark/Light themes based on system setting preference.
I have changed App Theme from Theme.AppCompat.Light.NoActionBar to Theme.AppCompat.DayNight.NoActionBar.
I am using this API on Application onCreate()
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
App theme is getting updated only when I restart app but does not update when I am within the app when theme is changed from system setting.
Am I missing any config changes?
I believe that the issue lies with the android:configChanges tag. This is because the activity needs to be recreated when the theme is changed. You will have to remove the tag and use onSavedInstanceState to save the state of your current activity.
I made a new Fragment and tried to set it's theme to AppCompat.NoActionBar using Android Studio's Design tool. The problem is, once I selected it, the theme did not change and stayed on the default app theme.
After Manually Setting the theme on the Android Manifest to Theme.AppCompat.NoActionBar the Fragment then accepted the Theme Change.
I want to ask the following:
Can Fragments have different Themes independent from the App Manifest or Main Activity? (Since I assume setting the Theme in the App Manifest changes it for all Activities and Fragments).
I was looking for a way to just set the Fragment's theme to AppCompat.NoActionBar but didn't get a way to do it without setting it in the App Manifest.
This is my First Question on StackOverFlow, hope it's a valid question since I couldn't find the answer online. :)
Is there a way to replicate the color changing ability provided by QKSMS .
It allows a user to select a color and then changes the app color and everything to that color.This is all done dynamically the moment the user chooses a specific color.
You can try this cool online tool: http://android-holo-colors.com
This enables you to create many themes for app widgets with your preferred color. You can then change your app theme by saving values for your theme in SharesPreferences or something similar and apply them in onCreate of each activity you have in your app. You can also create the themes easily in styles.xml. For each view, it has its own style with its own attributes so you will need to learn how to edit the theme of each view you want by searching...
Hope that helps.
Some Examples:
ActionBar:
https://developer.android.com/training/basics/actionbar/styling.html
Buttons:
https://www.androidcookbook.com/Recipe.seam?recipeId=3307
SeekBar:
Android - styling seek bar
Switch:
How can I style an Android Switch?
And a lot more... You will have to search for what you want.
I'm trying to get Simons Number Picker to work together with Holoeverywhere. however holoeverwhere requires me to set android:theme="#style/Holo.Theme" whereas the number picker requires android:theme="#style/SampleTheme.Light". I'm not very familiar with styles and themes yet, what are my options? Right now the number picker displays incorrectly:
PS. I need backwards comp. till 2.2 and would prefer keeping the holo theme
There is a built in NumberPicker in HoloEverywhere.
You can test it with the demo application.
org.holoeverywhere.widget.NumberPicker
Here is a link to the source code:
https://github.com/ChristopheVersieux/HoloEverywhere/blob/master/library/src/org/holoeverywhere/widget/NumberPicker.java
MOVED TO: https://github.com/Prototik/HoloEverywhere/blob/master/library/src/org/holoeverywhere/widget/NumberPicker.java
Maybe there is a way to use Simons widget on a dark theme, should be possible.