【发布时间】:2022-10-13 07:17:05
【问题描述】:
我想在转换期间更改约束布局中的可绘制角半径,但我还没有找到如何使用 xml 来实现,因为 CustomAttribute 标记仅支持可绘制颜色作为值。
<Constraint
android:id="@+id/layout_player"
android:layout_width="0dp"
android:layout_height="42dp"
android:background="@drawable/bg_player_control_part"
motion:layout_constraintBottom_toBottomOf="@+id/layout_parent_audio_player_card"
motion:layout_constraintEnd_toStartOf="@+id/tv_time_audio_small"
motion:layout_constraintStart_toEndOf="@+id/img_photo_audio_news_small">
<CustomAttribute
motion:attributeName="background"
motion:customColorDrawableValue="@drawable/bg_player_control_part" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/layout_player"
android:layout_width="0dp"
android:layout_height="42dp"
motion:layout_constraintBottom_toBottomOf="@+id/layout_parent_audio_player_card"
motion:layout_constraintEnd_toStartOf="@+id/tv_time_audio_small"
motion:layout_constraintStart_toEndOf="@+id/img_photo_audio_news_small">
<CustomAttribute
motion:attributeName="background"
motion:customColorDrawableValue="@color/color_bg_audio_player" />
</Constraint>
</ConstraintSet>```
【问题讨论】:
-
您是否尝试过直接在约束本身上设置它?同样在@id/end 集中,您尝试将颜色设置为背景(颜色与半径有何关系?)。为开始/结束状态创建可绘制对象。
-
我试图将 8dp 角半径更改为普通平面视图。所以在@id/end 里面我删除了drawable 并把颜色放到了视图中。但是当使用返回动画平面视图移动时,不会返回角视图。
-
我明白了,我的建议是创建具有所需形状和颜色的平面可绘制对象并将其设置为该值。
标签: android animation android-motionlayout