dark theme not changing button android studio code example
Example 1: dark mode change immediately swift
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return
}
appDelegate.changeTheme(themeVal)
func changeTheme(themeVal: String) {
if #available(iOS 13.0, *) {
switch themeVal {
case "dark":
window?.overrideUserInterfaceStyle = .dark
break
case "light":
window?.overrideUserInterfaceStyle = .light
break
default:
window?.overrideUserInterfaceStyle = .unspecified
}
}
}
Example 2: android studio change button color programmatically
Button11.setBackgroundColor(getResources().getColor(R.color.red));
Button11.setBackgroundColor(Button11.getContext().getResources().getColor(R.color.red));