Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
857 views
in Technique[技术] by (71.8m points)

themes - Android view setBackgroundColor() and night mode

I'm developing an android app and i need to allow user to choose via color picker the list view items's background color. Each listview item is a LinearLayout and i set the background color inside my adapter in this way:

holder.rowLayout.setBackgroundColor(this.backgroundColor!!)

All works perfectly in day mode but when the app switches to night mode i'm experiencing problems with colors.

Let's take this example: in day mode i choose bright green background and it correctly applies to the list:

enter image description here

But when i switch to night mode, colors are the following:

enter image description here

Now, i don't want to disable day ight to all the application. I've all my themes responsive to day ight preference, i just want to avoid dark mode to alter colors of this listview only since it's the user that choose its background color and i don't want Android to alter it.

I've tried to apply older themes to the linear layout and using LinearLayoutCompat without luck. Is there somebody that can help me?

question from:https://stackoverflow.com/questions/65946221/android-view-setbackgroundcolor-and-night-mode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...