1
我想要实现简单的任务 - 在对话框关闭之前,我想根据我的逻辑设置不同的关闭动画(getWindow()。getAttributes()。windowAnimations = ...)。例如,我在对话框上有2个按钮,如果按下第一个按钮,我想向左滑动,如果按下第二个按钮,向右滑动。我创建了一些带有android:windowExitAnimation和android:windowEnterAnimation动画的样式文件,如果在自定义对话框构造函数中传递,它们将工作。但我不能覆盖代码中的windowAnimations作为构造函数的方法不能使用,因为我需要不同的动画。如何做到这一点,以及为什么这段代码无法正常工作?在运行时更改动画
// close button
_button_close = (ImageButton)findViewById(R.id.buttonClose);
if (_button_close != null)
{
_button_close.setOnClickListener(
new Button.OnClickListener()
{
public void onClick(View v)
{
// set animation
getWindow().getAttributes().windowAnimations = R.style.DialogSlideOutLeft;
// close form
dismiss();
}
}
);
}
没有任何影响为了我 – stoefln