您的位置:首页 > 移动开发 > Android开发

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

2017-02-05 10:49 477 查看

问题描述:

    用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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android animation
相关文章推荐