user15573857
user15573857

Reputation:

dark mode interfering with background color

I'm trying to apply background colors to my app and for some reason I can't get the right colors

for example:

<View style={{backgroundColor:'yellow'}}></View>

but I'm getting

enter image description here enter image description here

the first one in system dark mode and second one in light mode ( settings & phone model )

so how do I get consistent colors in any mode?

Upvotes: 2

Views: 1953

Answers (2)

m_wer
m_wer

Reputation: 1524

I'm not quite sure if I understand you right. But I assume you don't want your App to be able to force dark mode right? Some of our users with the same Redmi Phone you mentioned also had the problem with forced dark mode which made the appearance pretty ugly.

If so, add the item 'forceDarkAllowed' set to false inside your /android/app/src/main/res/values/styles.xml

<resources>
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
    <item name="android:windowBackground">@drawable/launch_screen_bitmap</item>
    <item name="android:forceDarkAllowed">false</item>

Upvotes: 4

Meet Prajapati
Meet Prajapati

Reputation: 491

You should not hardcode the color like this. try to use color dynamically based on the light or dark theme.

Use the package like this :

react-native-appearance

Upvotes: 1

Related Questions