Changing theme of fabric digit screen - android

I have integrated fabric digits in my app and trying to change its theme.
I try using below code but i don't see any change in theme.What am i missing or doing wrong?
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:digits">#style/CustomDigitsTheme</item>
</style>
<style name="CustomDigitsTheme" parent="android:Theme.Material.Light" tools:targetApi="lollipop">
<item name="android:textColorPrimary">#color/white</item>
<item name="android:textColorSecondary">#android:color/darker_gray</item>
<item name="android:windowBackground">#color/blue</item>
<item name="android:textColorLink">#ff398622</item>
<item name="android:colorAccent">#ff398622</item>
</style

You need to add theme to your authButton, if you're using it, or directly to builder, if you're creating it manually.
You can find sample code in official docs.
For example:
//Example of setting theme with button
digitsAuthButton.setAuthTheme(android.R.style.Theme_Material);
or
//Example of setting theme manually with builder
new Digits.Builder().withTheme(themeId).build();`enter code here`
works as charm :)

Related

Customize Android TimePicker to use Spinner in .net Maui

I want to customize my TimePicker in .Net Maui to use the Spinner mode on Android(possible modes in android) and not the clock mode. Is this possible with Maui Handlers?
I was looking for something like this
#if ANDROID
Microsoft.Maui.Handlers.TimePickerHandler.Mapper.AppendToMapping("MyCustomization", (handler, view) =>
{
??? handler.PlatformView.TimePickerMode ???;
});
#endif
Or can I style it somehow?
The TimePicker's default mode is clock, and the attribute can just be set in the android layout xml or when it be created by calling the construction method. So you can't set it with the Muai Handler.
But you can use the android style to change the TimePicker's default mode.
Create the style.xml under the /Platform/Android/Resource/values folder:
<resources>
<style name="Spinner" parent="android:Widget.Material.Light.TimePicker">
<item name="android:timePickerMode">spinner</item>
</style>
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:timePickerStyle">#style/Spinner</item>
</style>
<style name="Splash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#android:color/holo_blue_dark</item>
<item name="android:windowSplashScreenIconBackgroundColor">#000000</item>
<item name="windowSplashScreenAnimatedIcon">#drawable/logo</item>
<item name="windowSplashScreenAnimationDuration">300</item>
<item name="postSplashScreenTheme">#style/AppTheme</item>
</style>
</resources>
In the AndroidManifest.xml:
<application android:allowBackup="true" android:theme="#style/Splash" android:icon="#mipmap/appicon" android:roundIcon="#mipmap/appicon_round" android:supportsRtl="true"></application>
Add the package named AndroidX.Core.SplashScreen in your android part.
Delete the (Theme="#style/Maui.SplashTheme") in the MainActivity and add the following code in the its OnCreate method's first line:
AndroidX.Core.SplashScreen.SplashScreen.InstallSplashScreen(this);
I have done a sample to test. The splash screen doesn't work when I set the item in the Maui.SplashTheme. So I declare another Theme for the application. But when I use the other control, the splash screen doesn't work.
So you can try to use the solution above or Just use the following code and set AppTheme as the MainActivity's theme. And then create a splash screen follwing the xamarin.android splash screen.
<resources>
<style name="Spinner" parent="android:Widget.Material.Light.TimePicker">
<item name="android:timePickerMode">spinner</item>
</style>
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:timePickerStyle">#style/Spinner</item>
</style>
</resources>

How to change style of PreferenceThemeOverlay / PreferenceFragmentCompat

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.

Alert Dialog Box Theme Issue

I am getting an error when trying to set theme for alertDialogbox. I am betting white box behind the alertdialogbox. Any idea how i can get rid of it? Here is my code for styles.xml.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowSoftInputMode">stateUnchanged|adjustPan</item>
<item name="android:alertDialogTheme">#style/alertTheme</item>
</style>
<style name="alertTheme" parent="#android:style/Theme.Holo.Light.Dialog">
</style>
In your values res folder, your alertDialogTheme should have the following property:
<!-- In API <21, this gives a funky background. Set to translucent -->
<item name="android:windowBackground">#color/translucent</item>
where #color/translucent is defined in colors.xml as #00000000, which gives opacity of 0.
In your values-v21 res folder, your alertDialogTheme should have the following property:
<!-- In API 21+, this is the dialog background color -->
<item name="android:windowBackground">#color/someColor</item>
This does nothing to alertDialogs in any API as far as I can tell:
<!--<item name="android:colorBackground">...</item>-->
I've only tested this on the Light AppCompat theme.
You do not provide any code, but in any way you should use AppCompat.
Your dialog style should inherit from AppCompat.Dialog
<style name="AlertDialog" parent="Theme.AppCompat.Light.Dialog"/>
and you should only use the AppCompat AlertDialog. Additionally you then pass in your style to the constructor.
new android.support.v7.app.AlertDialog.Builder(context, R.style.AlertDialog).show();
Without AppCompat
If you chose to try without AppCompat, be sure to test on multiple devices. You will need to provide different themes for phones before and after API 21 and handling the android:windowBackground yourself by either setting or hiding it.
Try adding to your alertTheme
<item name="android:background">#null</item>
Here goes a little bit improved answer of samGbos:
values/styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="android:alertDialogTheme">#style/SplashScreenDialog</item>
<item name="alertDialogTheme">#style/SplashScreenDialog</item>
</style>
...
<style name="SplashScreenDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowBackground">#android:color/transparent</item>
</style>
values-v21/styles.xml
...
<style name="SplashScreenDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
</style>

The different between <item name="title"> and <item name="android:title">

I make ActionBar in app.I change ActionBar style.There are some questions.
I want to change the title in the ActionBar.
So I write the follow code.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="actionBarStyle">#style/ActionBar</item>
<item name="actionOverflowButtonStyle">#style/overflowButton</item>
</style>
<!--ActionBar-->
<style name="ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/bg</item>
<item name="background">#color/bg</item>
<item name="android:title">#string/test</item>
<item name="title">#string/test</item>
</style>
<style name="overflowButton">
<item name="android:src">#mipmap/ic_add_black_48dp</item>
<item name="android:showAsAction"></item>
</style>
</resources>
when I only write <item name="android:title">#string/test</item> ,it doesn't work,but write <item name="title">#string/test</item> it work.
I have try to solve in Android Developer,but fail.Please help me.
<item name="title">#string/test</item>
this tag works on supporting library, and
<item name="android:title">#string/test</item>
this one works on your android. For more detail please have a look on here
I hope you understand, If not please let me know.
Note: If you are using the Support Library APIs for the action bar, then you must use (or override) the Theme.AppCompat family of styles (rather than the Theme.Holo family, available in API level 11 and higher). In doing so, each style property that you declare must be declared twice: once using the platform's style properties (the android: properties) and once using the style properties included in the Support Library (the appcompat.R.attr properties—the context for these properties is actually your app).

Custom theme and sherlockActionBar

I am doing a personal theme to use holo widget in 2.3 android.
I did this:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppThemes" parent="#style/Theme.Sherlock">
<item name="android:editTextStyle">#style/EditTextAppTheme</item>
<item name="android:checkboxStyle">#style/CheckBoxAppTheme</item>
<item name="android:radioButtonStyle">#style/RadioButtonAppTheme</item>
<item name="android:buttonStyle">#style/ButtonAppTheme</item>
<item name="android:imageButtonStyle">#style/ImageButtonAppTheme</item>
<item name="android:spinnerStyle">#style/SpinnerAppTheme</item>
<item name="android:dropDownSpinnerStyle">#style/SpinnerAppTheme.DropDown</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerDropDownItemAppTheme</item>
</style>
</resources>
the problem is that widgets don't take the correct style but take the default style. I tried to force assign the #style/EditTextAppTheme at an edittext and it worked.. so the problem is that the theme don't apply.
any idea?
update: the theme apply and work good..the solo problem is some edittext inside a dialog that show with the standard theme
To get the holo theme style in an App for API 10 and below, you can use HoloEverywhere. It's well integrated with ActionBarSherlock. ActionBarSherlock is included as a subproject. https://github.com/ChristopheVersieux/HoloEverywhere
If you want to use a customized Theme you have to set these style attributes in your Application theme. Then apply this theme to the whole App or to a single Activity by defining it in the manifest or setting it programmaticaly in the onCreate() method.
For example(for ABS):
<style name="Theme.myStyle" parent="Theme.Sherlock">
<item name="android:editTextStyle">#style/EditTextAppTheme</item>
<item name="android:checkboxStyle">#style/CheckBoxAppTheme</item>
<item name="android:radioButtonStyle">#style/RadioButtonAppTheme</item>
<item name="android:buttonStyle">#style/ButtonAppTheme</item>
<item name="android:imageButtonStyle">#style/ImageButtonAppTheme</item>
<item name="android:spinnerStyle">#style/SpinnerAppTheme</item>
<item name="android:dropDownSpinnerStyle">#style/SpinnerAppTheme.DropDown</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerDropDownItemAppTheme</item>
</style>
And then set this theme to your Application or your Activity in the Manifest with:
android:theme="#style/Theme.myStyle"
or programmatically:
setTheme(R.style.Theme.myStyle);

Categories

Resources