Android白天/夜间模式切换:NightOwl
这是一个实验项目,实现在Android上</span></span>切换白天/夜间模式。观看演示视频在油Tube上。mode on Andorid. View the demo video on 油Tube. add nightowllib library to your project which rely on init the NightOwl in Application class, such as then you need call three method in your Activity class, such as switch skin everywhere as you like Dependencies
compile 'com.android.support:appcompat-v7:23.1.0'</span></pre></div>
Setup
NightOwl.builder().defualt(MainApplication.sDefualtMode).create();
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); } }
View v = findViewById(R.id.button); v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { NightOwl.owlNewDress(SettingActivity.this); } });
</span></span>