Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] Kotlin Android App Use Default Device Theme(s)

Posted on November 11, 2022 By

Solution 1 :

Your applcation theme should inherit from DynamicColors like this:

values/themes.xml

<style name="Theme.App" parent="Theme.Material3.DynamicColors.Light">

</style>

Dark theme:
values-night/themes.xml

<style name="Theme.App" parent="Theme.Material3.DynamicColors.Dark">

</style>

Do not define colors like for example “colorPrimary” or “colorSurface” inside your Theme.App style.

Reference the created theme in your Manifest:

 <application
    ....
    android_theme="@style/Theme.App">

Problem :

I created a new Android app in Android Studio and selected a simple project template and Kotlin as the language. The app that’s generated has a purple toolbar and purple buttons. I know where those colors are defined (in the different color definitions in the project’s themes.xml file) but I want the app to just use the default themes (light and dark) currently defined on the device.

How do I disconnect the custom theme and just let the app use the defaults for the device. My device’s running Android 12, so the current theme could be dynamic.

Comments

Comment posted by johnwargo

That doesn’t solve my problem, I don’t want to have any custom colors or theme defined. My question is about how do I ONLY use the device themes in my app.

Comment posted by Philipp Schumann

Do not define custom colors. This theme uses the colors of your wallpaper on Android 12

Comment posted by johnwargo

so do what? delete the styles.xml file? Delete the color definitions somewhere? I’m trying to understand what to do to fix this

Comment posted by Philipp Schumann

I edited the answer so it is more straight forward what to do. You can leave your styles.xml as is. In general App themes should be defined in values/themes.xml and custom styles (e.g. a custom button style) should be defined in values/styles.xml.

READ  [FIXED] Android studio gradle build error: Could not get resource 'https://jcenter.bintray.com/.../.jar' in company firewall
Powered by Inline Related Posts

Comment posted by johnwargo

Thanks. I tried it but can’t make it work. I’ll dig into this more tomorrow.

Android Tags:android, kotlin, themes

Post navigation

Previous Post: [FIXED] android – Please help, after flutter update, (The name ‘MenuItem’ is defined in the libraries) in visual studio
Next Post: [FIXED] react-native: How to remove underline while typing text in TextInput Component on android device?

Related Posts

[FIXED] java – How to send images from PC to Android by using Socket? Android
[FIXED] android – Viewmodel preserving data after finishing activity Android
[FIXED] android – Attempt to invoke virtual method ‘java.lang.String java.lang.Object.toString()’ on a null object reference in onDataChange Android
[FIXED] react native – AppCenter cannot seem to find Android resources Android
[FIXED] java – Best way to notify multiple adapters Android
[FIXED] java – CLEARTEXT communication to XXX.XXX.XXX.XXX is not permitted by network security policy Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What are the main features of Islamic education?
  • Is the Jeep 4xe worth it?
  • How does the ringer work on cast iron?
  • What is the biggest size interior door?
  • Is blue raspberry an original Jolly Rancher flavor?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme