androidkotlintheme-daynight

Why i dont see some things in day/night mode


i have a problem with day and night mode becouse when i use night mode i see the menu bar and i dont see a button and when i use a day mode i dont see the menu bar but i se the button and i dont know what shoud i do (i see the add button in all modes but i dont see the retrive data button menu xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <item
        android:id="@+id/wyloguj"
        android:title="Wyloguj" />

</menu>

main xml

<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/szarytlo"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/addButton"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_marginEnd="32dp"
        android:layout_marginBottom="32dp"
        android:elevation="10dp"
        android:insetLeft="0dp"
        android:insetTop="0dp"
        android:insetRight="0dp"
        android:insetBottom="0dp"
        android:paddingStart="4dp"
        android:paddingEnd="4dp"
        app:cornerRadius="30dp"
        app:icon="@android:drawable/ic_input_add"
        app:iconGravity="textStart"
        app:iconPadding="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        tools:ignore="SpeakableTextPresentCheck" />

    <Button
        android:id="@+id/btnRetrieveData"
        android:textColor="@color/black"
        android:layout_width="226dp"
        android:layout_height="115dp"
        android:layout_marginTop="480dp"
        android:gravity="center"
        android:text="Retrieve Data"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.448"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/OsDlug"
        app:layout_constraintVertical_bias="1.0" />

    <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="245dp"
        android:layout_height="66dp"
        android:layout_marginTop="16dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/uzytkownik"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Witaj,"
            android:textColor="@android:color/black"
            android:textSize="18sp" />

    </ScrollView>

    <TextView
        android:id="@+id/dlug"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Osoby które musza oddac ci pieniadze to:"
        android:textColor="@color/black"
        android:textSize="20dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/scrollView2" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/OsDlug"
        android:layout_width="match_parent"
        android:layout_height="50dp"

        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/dlug" />




</androidx.constraintlayout.widget.ConstraintLayout>

themes day xml

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.NFC" parent="Theme.MaterialComponents.DayNight.NoActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/szary</item>
        <item name="colorPrimaryVariant">@color/szary</item>
        <item name="colorOnPrimary">@color/white</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_700</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
        <!-- Customize your theme here. -->
    </style>
</resources>

themes night xml

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.NFC" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/szary</item>
        <item name="colorPrimaryVariant">@color/szary</item>
        <item name="colorOnPrimary">@color/black</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_200</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
        <!-- Customize your theme here. -->
    </style>
</resources>

Solution

  • Themes.xml

    <resources xmlns:tools="http://schemas.android.com/tools">
        <!-- Base application theme. -->
        <style name="Theme.DoktaraSor" parent="Theme.MaterialComponents.DayNight.NoActionBar">
            <!-- Primary brand color. -->
            <item name="colorOnPrimary">@color/white</item>
            <!-- Secondary brand color. -->
            <item name="colorSecondary">@color/teal_200</item>
            <item name="colorSecondaryVariant">@color/teal_700</item>
            <item name="colorOnSecondary">@color/black</item>
    
            <!-- Customize your theme here. -->
        </style>
    </resources>
    

    Themes.xml(night)

    <resources xmlns:tools="http://schemas.android.com/tools">
        <!-- Base application theme. -->
        <style name="Theme.MaterialComponents.DayNight.DarkActionBar">
            <!-- Primary brand color. -->
            <item name="colorPrimary">@color/purple_200</item>
            <item name="colorPrimaryVariant">@color/purple_700</item>
            <item name="colorOnPrimary">@color/black</item>
            <!-- Secondary brand color. -->
            <item name="colorSecondary">@color/teal_200</item>
            <item name="colorSecondaryVariant">@color/teal_200</item>
            <item name="colorOnSecondary">@color/black</item>
            <!-- Customize your theme here. -->
        </style>
    </resources>
    

    Hello again, do you recognize me?. After doing this you may have to give background to all objects

    it won't make any difference even if you change it day/night hopefully :D :D