I want to add the same theme changing animation
I have a radioGroup

where onChangeListener changes themes
I want to achive this:
when you check Dark radio, the animation will start from the position of dark radio
if you check light, it will start from light and etc
How is it possible to make such kind of animation in andoid app?
my full theme chaning code:
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();
}

