Android白天/夜間模式切換:NightOwl

jopen 9年前發布 | 21K 次閱讀 NightOwl Android開發 移動開發

是一個實驗項目,實現在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'

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);
}

}</pre>

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.baiduhome.net/lib/view/home/1447421375928

</span></span>

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!