在我的res / animator / back.xml文件中,如何从中访问值 res / values / dimens.xml?
<translate
android:fromXDelta="0%" android:toXDelta="-100%"
android:duration="@dimen/anim_time"
/>
值文件:
<resources>
<integer name = "anim_time">500</integer>
</resources>
答案 0 :(得分:1)
您的问题是 dimen 访问整数值。 下面的代码没有任何问题:
<translate
android:fromXDelta="0%" android:toXDelta="-100%"
android:duration="@integer/anim_time" />
请参阅有关duration
属性的AnimationDrawable文档:
This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.
所以,如果你的值是整数,那么它的类型应该是integer
。实际上,上述文档不允许使用维度值。