Fixed
Status Update
Comments
di...@google.com <di...@google.com>
ho...@google.com <ho...@google.com>
ni...@google.com <ni...@google.com>
ni...@google.com <ni...@google.com> #2
Information redacted by Android Beta Feedback.
Description
In video file you can see red view is not visible when setting MotionScene in code, but showing when we are setting layoutDescription in layout file.
MainActivity.kt
class MainActivity : AppCompatActivity() {
val TAG = MainActivity::class.java.simpleName
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
mainMotionLayout.loadLayoutDescription(R.xml.serial_scene)
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="
xmlns:app="
xmlns:tools="
android:id="@+id/mainMotionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<View
android:id="@+id/view"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="@color/colorPrimary"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/view2"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="120dp"
android:layout_marginLeft="120dp"
android:background="@color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.motion.widget.MotionLayout>
serial_scene.xml
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="
xmlns:motion="
<Transition
android:id="@+id/firstTransition"
motion:constraintSetEnd="@id/constraintEnd"
motion:constraintSetStart="@id/constraintStart">
<OnSwipe
motion:dragDirection="dragUp"
motion:touchAnchorId="@id/view"
motion:touchAnchorSide="bottom" />
</Transition>
<ConstraintSet android:id="@+id/constraintStart">
<Constraint
android:id="@id/view"
android:layout_width="60dp"
android:layout_height="60dp"
motion:layout_constraintLeft_toLeftOf="parent"
motion:layout_constraintRight_toRightOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/constraintEnd">
<Constraint
android:id="@id/view"
android:layout_width="60dp"
android:layout_height="60dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintLeft_toLeftOf="parent"
motion:layout_constraintRight_toRightOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
</MotionScene>