Mar*_*ert 26 android android-animation android-lint
我已将我的SDK更新到最新版本,但现在我收到了一个lint错误.
错误:animator类型的预期资源[ResourceType]
此行发生错误:
AnimatorInflater.loadAnimator(context, R.anim.right_slide_in)
Run Code Online (Sandbox Code Playgroud)
引用的资源/res/anim/right_slide_in.xml如下所示:
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:valueTo="0"
android:valueFrom="1.0"
android:propertyName="xFraction"
android:valueType="floatType"
android:duration="450" />
Run Code Online (Sandbox Code Playgroud)
它以前总是奏效.有人可以解释为什么我会收到这个错误吗?
Xav*_*ler 75
发生此错误是因为您将Animator资源存储在错误的目录中!它以前工作,因为AnimatorInflater无论在哪个文件夹中保存它都可以加载xml.
R.anim.*res/anim/文件夹中的资源用于查看动画.R.animator.*该/res/animator/文件夹中的资源用于Animators.因此,要修复错误,只需将Animator资源/res/anim/移至/res/animator/.
在将资源类型注释添加到支持库之前,这根本没有任何区别.这些注释很长,还有许多新的lint支票,其中包括绊倒你的那个.
将来,如果你收到这样的错误,你可以查看注释,找出你做错了什么.例如实施loadAnimator()了的AnimatorInflater这个样子的:
public static Animator loadAnimator(Context context, @AnimatorRes int id)
throws NotFoundException {
return loadAnimator(context.getResources(), context.getTheme(), id);
}
Run Code Online (Sandbox Code Playgroud)
@AnimatorResid参数的注释表示Animator此处只应传递资源.如果你看一下@AnimatorRes它的文档就像这样:
表示整数参数,字段或方法返回值应该是动画师资源引用(例如android.R.animator.fade_in).
如果描述没有解释错误,那么示例通常会;)
| 归档时间: |
|
| 查看次数: |
16045 次 |
| 最近记录: |