我正在尝试使用 MotionLayout 制作动画,我需要隐藏一些元素。我在单个元素中测试了可见性属性并且它有效,但是为了使 XML 更短,我希望能够仅指定一个包含所有这些元素的组(来自 ConstraintLayout 助手)
像这样的东西
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Transition
app:constraintSetStart="@id/start"
app:constraintSetEnd="@id/end"
app:duration="300">
<OnSwipe
app:touchAnchorId="@id/details_group"
app:touchAnchorSide="bottom"
app:dragDirection="dragDown"
/>
</Transition>
<ConstraintSet
android:id="@+id/start">
<Constraint
android:id="@+id/details_group"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:constraint_referenced_ids="detail_value_topl,detail_icon_topl,detail_value_topr" />
</ConstraintSet>
<ConstraintSet
android:id="@+id/end">
<Constraint
android:id="@+id/details_group"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="visible"
app:constraint_referenced_ids="detail_value_topl,detail_icon_topl,detail_value_topr" />
</ConstraintSet>
</MotionScene>
Run Code Online (Sandbox Code Playgroud)
但它不起作用,知道如何使它起作用吗?
另外,我不想使用 alpha,因为所有约束都已设置,以便当它们消失时容器会调整大小
我正在用Java做一个简单的游戏,我有这个疑问.
假设每个游戏角色都有一个界面
public interface Entity{
Vector2 getPosition();
/* More methods...*/
}
Run Code Online (Sandbox Code Playgroud)
然后我想创建一个名为Automata的接口,由每个使用AI东西的类实现(这可能是Entity的一个特例,但我认为它因为可重用性而单独考虑)
public interface Automata{
Vector2 getPosition(); // The AI stuff needs to know this
/* More methods needed for AI (some may also be the same as Entity)... */
}
Run Code Online (Sandbox Code Playgroud)
我认为这促进了模块化,因为每个接口都描述了它的方法,而不用担心其他接口的存在,但是当我写这篇文章时,我觉得我在重复自己,所以这两个(或可能更多)接口使用相同的方法什么坏事?