PopupWindow动画崩溃设备

时间:2016-04-20 21:03:58

标签: android animation

我一直在尝试在PopupWindow上运行一个简单的缩放动画。

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
    android:duration="800"
    android:fromXScale="1.0"
    android:fromYScale="0.0"
    android:interpolator="@android:anim/linear_interpolator"
    android:pivotX="0"
    android:pivotY="0"
    android:toXScale="1.0"
    android:toYScale="1.0" />
</set>

一切都工作得很好,直到我将持续时间改为大约3000.从那时起,我在Android 5.0(API 21)上运行的Galaxy S5只会挂起几秒钟然后崩溃。 这是处理PopupWindow的方法。

if(noConnectionPopup == null || !noConnectionPopup.isShowing()) {
        LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
        ViewGroup view = (ViewGroup) inflater.inflate(R.layout.no_connection_popup, null);
        noConnectionPopup = new PopupWindow(view,FrameLayout.LayoutParams.MATCH_PARENT,(int)(toolbar.getHeight() * 1.5),false);
        noConnectionPopup.setAnimationStyle(R.style.Animation);
        noConnectionPopup.showAsDropDown(toolbar, 0, 0);
    }

这是动画风格资源。

<style name="Animation">
    <item name="android:windowEnterAnimation">@anim/no_connection_popup_show</item>
    <item name="android:windowExitAnimation">@anim/no_connection_popup_hide</item>
</style>

这是布局膨胀。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
    android:background="@color/colorAccent"
    android:gravity="left|center_vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textColor="@color/colorButtonText"
    android:text="No connection"
    android:textSize="30sp" />

</FrameLayout>

我现在尝试了一切。似乎问题是XScale保持不变,但我仍然无法理解为什么它适用于较小的持续时间。在模拟器中,它适用于任何持续时间。有什么问题,有什么我可以做的吗?

0 个答案:

没有答案