gpt4 book ai didi

java - Android 应用主题改变时的波纹类动画

转载 作者:行者123 更新时间:2023-12-05 00:19:02 25 4
gpt4 key购买 nike


我想添加相同的主题变化动画

enter image description here(这是电报应用程序)

我有一个radioGroup
enter image description here
onChangeListener 改变主题的地方
我想实现这个:
当勾选Dark radio时,动画会从dark radio的位置开始
如果你检查光,它会从光等开始
怎么可能在andoid 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 库:https://github.com/imandolatkia/Android-Animated-Theme-Manager

在此库中,您可以创建自定义主题并使用涟漪动画动态更改它们,如您的问题图片

enter image description here

关于java - Android 应用主题改变时的波纹类动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64946766/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com