Category : android-dark-theme

I have editText in my layout <EditText android:id="@+id/etMarks1" style="@style/Marks"/> and theme.xml <style name="Marks" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> <item name="android:layout_weight">15</item> <item name="android:ems">1</item> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:inputType">number</item> <item name="android:textSize">18sp</item> <item name="android:gravity">center</item> </style> The tint line color is black by default and it is changing to white in night mode when I tested in Samsung and Pixel devices (Android ..

Read more

We developing home screen widgets in 2021 and I tried to implement dark theme support. According to https://developer.android.com/guide/topics/ui/look-and-feel/darktheme#widgets "… use appropriate theme attributes instead of hardcoded colors." So as I understand I can use custom attributes and I added attrs.xml in values folder <?xml version="1.0" encoding="utf-8"?> <resources> <attr name="customBackgroundColor" format="color" /> </resources> After that I ..

Read more

I know it might be easy but is just something that I don’t know. I am new at coding and I tried different codes in my app. The code that I currently used does nothing: aSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked){ switch (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) { case Configuration.UI_MODE_NIGHT_YES: ..

Read more

I would like to apply the Dark mode to my app for Android 10 and greater. Therefore I wrote following code on startup: int modeNight; int colorMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; if (colorMode == Configuration.UI_MODE_NIGHT_YES) { modeNight = AppCompatDelegate.MODE_NIGHT_YES; } else { modeNight = AppCompatDelegate.MODE_NIGHT_NO; } AppCompatDelegate.setDefaultNightMode(modeNight); This works in general. If I start the ..

Read more