Android白天/夜间模式切换:NightOwl

jopen 9年前

是一个实验项目,实现在Android上</span></span>切换白天/夜间模式观看演示视频在油Tube上。mode on Andorid. View the demo video on 油Tube.

Dependencies

add nightowllib library to your project which rely on

compile 'com.android.support:appcompat-v7:23.1.0'</span></pre></div>  

Setup

init the NightOwl in Application class, such as

 NightOwl.builder().defualt(MainApplication.sDefualtMode).create();

then you need call three method in your Activity class, such as

public class DemoActivity extends AppCompatActivity {      @Override      protected void onCreate(Bundle savedInstanceState) {          // step1 before super.onCreate          NightOwl.owlBeforeCreate(this);            super.onCreate(savedInstanceState);          setContentView(R.layout.activity_demo);            // step2 after setContentView          NightOwl.owlAfterCreate(this);            // write your code      }        @Override      protected void onResume() {          super.onResume();            // step3 onResume          NightOwl.owlResume(this);      }    }

switch skin everywhere as you like

View v = findViewById(R.id.button);  v.setOnClickListener(new View.OnClickListener() {      @Override      public void onClick(View v) {          NightOwl.owlNewDress(SettingActivity.this);      }  });

项目主页:http://www.open-open.com/lib/view/home/1447421375928

</span></span>