How do I specify a tint color to an imageView as a custom attribute when using MotionLayout. Currently I can only specify a custom background color in my MotionScene
xml file:
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/imageView"
android:layout_width="180dp"
android:layout_height="180dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintVertical_bias="0.75"
motion:srcCompat="@drawable/ic_android_black_24dp" >
<CustomAttribute
motion:attributeName="backgroundColor"
motion:customColorValue="#9999FF" />
</Constraint>
</ConstraintSet>
Note that you are using backgroundColor
but the attribute is android:background
. For tint
you should write:
<CustomAttribute
motion:attributeName="ColorFilter"
motion:customColorValue="#9999FF" />
As far as I know, the feature of CustomAttribute
uses reflection and not the attributes from xml etc. Keep that in mind for all custom attributes.
You can use ColorFilter.
<CustomAttribute
motion:attributeName="colorFilter"
motion:customColorValue="@color/your_tint_color" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With