• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Light/Dark mode

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone!
I am trying to change the background of an apk via android studio, using a function?
The idea is to make a "light/dark" mode by using a switch button.
Could anyone give me a lead on how I could do this please?
 
Saloon Keeper
Posts: 6888
163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "via Android Studio" - are you talking about adding code and a UI for doing this in an app of yours? If so, I assume that adding a UI is not an issue (it would just be a checkbox or whatever that triggers switching the mode when touched).

At least as important as doing this manually is hooking into the system-wide setting. See https://developer.android.com/guide/topics/ui/look-and-feel/darktheme for all about that.

That page also explains the API calls you can use to set the mode programmatically in your app, if you don't just want to follow the system setting.
 
Darius Boteand
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the help!
I will let you know how I am progressing with this!
 
I promise I will be the best, most loyal friend ever! All for this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic