android2.3使用AnimationUtils.loadAnimation()加载动画出现异常

    xiaoxiao2021-03-26  28

    问题描述:

        用 AnimationUtils.loadAnimation()方法加载动画,在android5.0上正常,在android2.3上异常闪退。     动画xml文件:      <?xml version="1.0" encoding="utf-8"?>     <set xmlns:android=" http://schemas.android.com/apk/res/android">         <scale             android:duration="100"             android:interpolator="@android:interpolator/accelerate_quad"             android:fillAfter="true"             android:fillBefore="true"             android:fromXScale="100%"             android:fromYScale="100%"             android:pivotX="0"             android:pivotY="0"             android:toXScale="100%"             android:toYScale="0%" />     </set>

    问题原因:

        (1).在xml中配置插补器最低api要求是11,项目中配置的是8          (2).弃用xml中配置的插补器后仍报错,异常如下,最后发现是android低版本不支持 fromXScale、 fromYScale 等参数值为100%、0%的转换     

    解决方案:

    (1).弃用xml中的插补器配置 (2).fromXScale、fromYScale的值改为Float类型 最后修改后的动画xml文件如下,在android2.3上正常加载: <?xml version="1.0" encoding="utf-8"?> <set xmlns:android=" http://schemas.android.com/apk/res/android" >     <scale         android:duration="100"         android:fillAfter="true"         android:fillBefore="true"         android:fromXScale="1.0"         android:fromYScale="1.0"         android:pivotX="0"         android:pivotY="0"         android:toXScale="1.0"         android:toYScale="0.0" /> </set>
    转载请注明原文地址: https://ju.6miu.com/read-659701.html

    最新回复(0)