<?xml version="1.0" encoding="utf-8"?>
#35464e
#212a2f
#212a2f
#616161
#212a2f
@android:color/holo_blue_dark
values中的strings.xml
DayNight
日间模式
values-night中的strings.xml
DayNight
夜间模式
public class MainActivity extends AppCompatActivity {
private Button mDayNightChange;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDayNightChange = (Button) findViewById(R.id.day_night_change);
mDayNightChange.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int mode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT