我刚刚开始使用MotionLayout,到目前为止,它确实很容易,而且我也获得了所需的输出。但是日志中充满错误E / MotionPaths:UNKNOWN customName ImageAlpha
motion:attributeName是必需的,并且必须与具有getter和setter方法的对象匹配。吸气剂和塞特剂非常匹配特定的模式。
所以,我在这里做错了什么?
motion_layout.xml
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@id/end"
motion:constraintSetStart="@id/start">
<OnSwipe
motion:dragDirection="dragUp"
motion:touchAnchorId="@id/store_viewpager"
motion:touchAnchorSide="top" />
<KeyFrameSet>
<KeyAttribute
motion:framePosition="60"
motion:motionTarget="@id/tab_image_view">
<CustomAttribute
motion:attributeName="imageAlpha"
motion:customIntegerValue="255" />
</KeyAttribute>
<KeyAttribute
motion:framePosition="90"
motion:motionTarget="@id/tab_image_view">
<CustomAttribute
motion:attributeName="imageAlpha"
motion:customIntegerValue="0" />
</KeyAttribute>
</KeyFrameSet>
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/tab_image_view"
android:layout_height="256dp"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/tab_image_view"
android:layout_height="96dp"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent">
</Constraint>
</ConstraintSet>
</MotionScene>
表示找不到“ imageAlpha”。您的customAttributes表示您在“ @ + id / tab_image_view”上有setImageAlpha(int)方法。
假设它是一个ImageView可以正常工作,但只能返回到api 16。从0.0到1.0,Alpha更为通用,并且在View上。您不需要自定义属性。 android:alpha =“ 0”
为了进一步帮助您,视图是什么? (ImageView?)什么设备级别?