Code Monkey home page Code Monkey logo

nightmode's Introduction

NightMode

alt text

Download APK :

https://github.com/datanapps/NightMode/blob/master/screens/app-debug.apk

Implement night mode in your application.

1. Create a folder app --> res --> values-night

2. Copy and paste from colors.xml and styles.xml from values folder

3. Make changes in styles and colors

colors.xml :

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <color name="colorPrimary">#008577</color>
        <color name="colorPrimaryDark">#00574B</color>
        <color name="colorAccent">#D81B60</color>

        <color name="colorWhite">#FFFFFF</color>
        <color name="colorBlack">#000000</color>
    </resources>

styles.xml (use DayNight theme Theme.AppCompat.DayNight.DarkActionBar)

      <resources>

          <style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
              <item name="colorPrimary">@color/colorPrimary</item>
              <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
              <item name="colorAccent">@color/colorAccent</item>
              <item name="android:windowBackground">@color/colorBlack</item>
              <item name="android:textColorPrimary">@color/colorWhite</item>
              <item name="android:textColorSecondary">@color/colorWhite</item>
          </style>

      </resources>

4. Create Application class and add into manifest file. this application class will handle to app scrren

         public class MyApplication extends Application {

          @Override
          public void onCreate() {
              super.onCreate();
              // AppCompatDelegate.MODE_NIGHT_NO,   AppCompatDelegate.MODE_NIGHT_YES, AppCompatDelegate.MODE_NIGHT_AUTO
              AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);
          }
      }

5. To implement special in Activity write code in activity otherwise write code on application.

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO);

before super().

Example :

      public class MainActivity extends AppCompatActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {

            // AppCompatDelegate.MODE_NIGHT_NO,   AppCompatDelegate.MODE_NIGHT_YES, AppCompatDelegate.MODE_NIGHT_AUTO
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);

            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);


        }
    }

nightmode's People

Contributors

datanapps avatar yogendra-mediacorp avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.