我想给我的android.support.v7.widget.CardView
添加高度动画,就像材料风格的Button
一样。我已经尝试设置了一个StateListAnimator
:
android:stateListAnimator="@anim/selector_raise"
这指向了我在 res/anim
中的选择器:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:state_pressed="true">
<objectAnimator android:duration="@android:integer/config_shortAnimTime"
android:propertyName="translationZ" android:valueTo="@dimen/touch_raise"
android:valueType="floatType" />
</item>
<item>
<objectAnimator android:duration="@android:integer/config_shortAnimTime"
android:propertyName="translationZ" android:valueTo="0dp"
android:valueType="floatType" />
</item>
</selector>
但是Android Studio给了我一个错误:
元素选择器必须被声明
正确的做法是什么?