- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我已将我的 SDK 更新到最新版本,但现在出现 lint 错误。
Error: Expected resource of type animator [ResourceType]
错误发生在这一行:
AnimatorInflater.loadAnimator(context, R.anim.right_slide_in)
引用的资源 /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" />
它以前总是有效的。有人可以解释为什么我会收到这个错误吗?
最佳答案
发生错误是因为您将 Animator
资源存储在错误的目录中!它以前工作过,因为 AnimatorInflater
可以加载 xml,而不管它保存在哪个文件夹中。
res/anim/
文件夹中的
R.anim.*
资源用于查看动画。
/res/animator/
文件夹中的
R.animator.*
资源用于
Animators
。
所以要修复错误,只需将 Animator
资源从 /res/anim/
移动到 /res/animator/
。
在将资源类型注释添加到支持库之前,这根本没有任何区别。除了这些注释之外,还有许多新的 lint 检查,这些检查让你绊倒了。
以后如果您遇到这样的错误,您可以查看注释以找出您做错了什么。例如 AnimatorInflater
的 loadAnimator()
的实现如下所示:
public static Animator loadAnimator(Context context, @AnimatorRes int id)
throws NotFoundException {
return loadAnimator(context.getResources(), context.getTheme(), id);
}
id参数上的@AnimatorRes
注解表示这里只需要传递Animator
资源。如果您查看 @AnimatorRes
的文档,它的内容如下:
Denotes that an integer parameter, field or method return value is expected to be an animator resource reference (e.g. android.R.animator.fade_in).
如果描述没有解释错误,那么示例通常会解释;)
关于android - 动画师类型的预期资源 [ResourceType],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34293718/
我正在开发一个统一游戏,基本上,我有一个预制件,里面有一个 Sprite 。我创建了一个附加到该 Sprite 的动画。 FrogPrefab |__ FrogSprite 我创建了一个带有公
我制作了一款游戏,当你死后,分数会使用动画从右上角移动到屏幕中间。当您按下“重试”时,我通过设置用作 AnimationState 中的速度倍增器的速度参数来反转动画。 当参数切换值(从 1.0 到
我对 Unity 和一般编码还是陌生的,所以请记住这一点!我也在 Unity 论坛上问过这个问题,但人们告诉我代码应该可以正常编译,而且他们不知所措,所以我希望能在这里找到一些答案! 我试图让我的步行
是否可以将 alpha 动画器应用于 元素而不是整体 AnimatedVectorDrawable 中的元素?如果没有,是否有其他替代方案? 最佳答案 不,元素没有 alpha 属性。 根据 Vec
我是 Cocoa 新手。 我正在努力扩展项目的功能。 该项目的原始功能是打开一个文件并在nsbox(在nswindow中?)中显示文件图标 当我单击菜单打开时,它工作正常。 但是当我以编程方式打开文件
我是一名优秀的程序员,十分优秀!