0

Hello i want to know that how can i set a fixed color to ui elements wheather the android device is in light mode or in dark mode

Here in my case there are some issues where the View in light mode of the device is set to my given color backgroud in light mode but when i switch the device to dark mode the View change its color to darkgrey which i didnt set

is there any way to fix this issues and also any tips on how can i do this in future with every ui element

Here is my Code

BottomSheet.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <View
        android:id="@+id/slidedownview"
        android:layout_width="40dp"
        android:layout_height="3dp"
        android:layout_alignParentTop="true"
        android:layout_centerInParent="true"
        android:layout_marginTop="10dp"
        android:background="@drawable/rounded_corner_bottomsheetline"/>

</RelativeLayout> 

rounded_corner_bottomsheetline

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:endColor="@color/lite_grey"
        android:startColor="@color/lite_grey" />
    <corners
        android:bottomLeftRadius="25dp"
        android:bottomRightRadius="25dp"
        android:topLeftRadius="25dp"
        android:topRightRadius="25dp" />

</shape>

color code

<color name="lite_grey">#e2e2e2</color>

Output //Dark Mode

as you can see the view is in dark grey color which i dint set ,the color i set is #e2e2e2

enter image description here

Output // Normal or Light Mod

enter image description here

Vasant Raval
  • 257
  • 1
  • 12
  • 31

1 Answers1

0

Check the themes.xml folders and set the same colour everywhere for both day and night themes

ADITYA RANADE
  • 293
  • 3
  • 10