• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Light/Dark mode

 
Ranch Hand
Posts: 56
  • 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: 7631
177
  • 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: 56
  • 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!
 
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic