【发布时间】:2021-08-21 19:57:13
【问题描述】:
我想添加相同的主题更改动画
我有一个radioGrouponChangeListener 更改主题
我想实现这个:
当您选中暗单选时,动画将从暗单的位置开始
如果您检查灯光,它将从灯光等开始
安卓app怎么能做出这样的动画?
我的完整主题转换代码:
public void chooseTheme(MenuItem item) {
final AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
final View mView = getLayoutInflater().inflate(R.layout.dialog_theme,null);
Button btn_cancel = mView.findViewById(R.id.btn_cancel);
Button btn_okay = mView.findViewById(R.id.btn_okay);
alert.setView(mView);
final AlertDialog alertDialog = alert.create();
alertDialog.setCanceledOnTouchOutside(false);
final RadioGroup themeGroup = mView.findViewById(R.id.themeGroup);
btn_cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertDialog.dismiss();
}
});
themeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@SuppressLint("NonConstantResourceId")
@Override
public void onCheckedChanged(RadioGroup themeGroup, int i) {
switch(i) {
case R.id.radioLight:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
setTheme(R.style.AppTheme);
Toast.makeText(getApplicationContext(),"Light mode",Toast.LENGTH_LONG).show();
restartApp();
break;
case R.id.radioDark:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
setTheme(R.style.darkTheme);
Toast.makeText(getApplicationContext(),"Dark mode", Toast.LENGTH_LONG).show();
restartApp();
break;
case R.id.radioSystem:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
Toast.makeText(getApplicationContext(),"System mode", Toast.LENGTH_LONG).show();
restartApp();
break;
}
}
});
btn_okay.setOnClickListener(new View.OnClickListener() {
@SuppressLint("SetTextI18n")
@Override
public void onClick(View v) {
alertDialog.dismiss();
}
});
alertDialog.show();
}
public void restartApp() {
Intent i = new Intent(getApplicationContext(),MainActivity.class);
startActivity(i);
finish();
}
【问题讨论】:
-
查看这个github项目:github.com/danieleorlando/CircularReveal
-
有意思,我去看看,谢谢!