弹出窗口动画不起作用

3
我正在尝试使用 push_up 动画从视图底部显示弹出窗口,并在关闭时使用 push_up out 动画进行动画处理。但是它没有起作用,弹出窗口以默认动画(非常快)正常显示。 以下是我的代码:

push_up_in.xml

<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
        android:duration="1000"
        android:fromYDelta="100%p"
        android:toYDelta="0" />

    <alpha
        android:duration="1000"
        android:fromAlpha="0.0"
        android:toAlpha="1.0" />
</set>

push_up_out.xml

<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
        android:duration="1000"
        android:fromYDelta="0"
        android:toYDelta="-100%p" />

    <alpha
        android:duration="1000"
        android:fromAlpha="1.0"
        android:toAlpha="0.0" />
</set>

styles.xml

<style name="popup_anim">
    <item name="android:windowEnterAnimation">@anim/push_up_in</item>
    <item name="android:windowExitAnimation">@anim/push_up_out</item>
</style>

而在代码中显示弹出窗口的位置:
final PopupWindow pw = new PopupWindow(popview, 100, 100, true);
pw.setBackgroundDrawable(new BitmapDrawable());
pw.setOutsideTouchable(true);
pw.setAnimationStyle(R.style.popup_anim);
pw.showAtLocation(this.findViewById(R.id.map_layout),
                    Gravity.BOTTOM, 0, 0);
View map = (View) findViewById(R.id.map);
int mapwidth = map.getWidth();
int mapheight = map.getHeight();
int popuph = (int) (mapheight * 0.3);
pw.update(mapwidth, popuph);

任何想法?
1个回答

1

我看不到你设置内容视图的地方,可能没有内容可以显示。 如果不是这个问题,尝试将背景可绘制对象设置为null,并在其中设置布局的背景,这解决了我的项目中颜色显示错误的一些问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接