Android 自定义对话框显示动画不工作
我正在使用customDialog,并尝试播放动画。我写了一些动画xml,但当我调用dialog时,它不工作 对话框调用方法Android 自定义对话框显示动画不工作,android,android-animation,customdialog,Android,Android Animation,Customdialog,我正在使用customDialog,并尝试播放动画。我写了一些动画xml,但当我调用dialog时,它不工作 对话框调用方法 void openDiaog(){ Dialog dialog = new Dialog(MainActivity.this,android.R.style.Theme_Holo_Light_NoActionBar_Fullscreen); dialog.setContentView(R.layout.cdialog); dialog.setTit
void openDiaog(){
Dialog dialog = new Dialog(MainActivity.this,android.R.style.Theme_Holo_Light_NoActionBar_Fullscreen);
dialog.setContentView(R.layout.cdialog);
dialog.setTitle("Dialog");
dialog.getWindow().setWindowAnimations(R.style.DialogTheme);
/* I try this but result is same!
dialog.getWindow().getAttributes().windowAnimations =
*/
dialog.show();
}
左滑动画
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="100%p" android:toXDelta="0"
android:duration="500" />
右转动画
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromXDelta="0"
android:toXDelta="100%p" />
动画主题
<style name="DialogTheme">
<item name="android:windowEnterAnimation">@anim/slide_left</item>
<item name="android:windowExitAnimation">@anim/slide_right</item>
</style>
@动画/幻灯片左
@动画/幻灯片右
试试这个。它将创建内部视图的动画
((ViewGroup)dialog.getWindow().getDecorView()).getChildAt(0).startAnimation(AnimationUtils.loadAnimation(context,android.R.anim.slide_in_left));
这些解决方案都不起作用。非常感谢。