Comments (5)
Could you provide more context?
Ideally a sample MotionScene and layout file.
from constraintlayout.
I think issue caused by I have custom motionInterpolator. When I remove it, Switch work fine.
<Transition
motion:constraintSetEnd="@id/set_second"
motion:constraintSetStart="@id/set_first"
motion:motionInterpolator="cubic(0.34, 1.56, 0.64, 1)"
motion:duration="300">
</Transition>
from constraintlayout.
Is this part of the starting constraint set or the ending constraint set?
What did you think would happen ?
You cannot animate between a true and a false.
from constraintlayout.
This is my scene file onboard_scene.xml
:
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<ConstraintSet android:id="@+id/set_first" />
<ConstraintSet android:id="@+id/set_second">
<Constraint
android:id="@id/switchDemo">
<CustomAttribute
motion:attributeName="checked"
motion:customBoolean="true" />
</Constraint>
</ConstraintSet>
<Transition
motion:constraintSetEnd="@id/set_second"
motion:constraintSetStart="@id/set_first"
motion:motionInterpolator="cubic(0.34, 1.56, 0.64, 1)"
motion:duration="300">
</Transition>
</MotionScene>
This is my layout file onboard.xml
:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layoutOnboard"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/onboard_scene">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/switchDemo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.motion.widget.MotionLayout>
When animation start, switch change color first, then change state. You can run the code to observe.
from constraintlayout.
The behavior is a little different in 2.1. But I don't think it is what you expected.
You did not state how you triggered the transition.
In general for any bug state:
- What you did (sample code)
- What you expected.
- What happened.
Several issue with your code.
- You are not triggering the transition.
- Typically you have a CustomAttribute at the start and the end constraint set.
- You seem to expect something to happen at the start?
Generally the way MotionLayout works a transition has 3 phases:
- The starting constraintSet is applied (Progress = 0.0)
- Any floating/integer variables that are different between the start and end are repeatedly applied. (Progress = 0.0-1.0)
- The ending constraintSet is applied (Progress =1.0)
from constraintlayout.
Related Issues (20)
- Support for compose multiplatform HOT 1
- MotionLayout OnSwipe only animated after first ACTION_UP HOT 2
- topMargin is abnormal HOT 8
- In Android8.1 (27), the round setting is too large, and the ImageFilterView cannot be displayed HOT 2
- Comprehensive guide/documentation for swing constraintlayout HOT 2
- Carousel changes views randomly if used inside a RecyclerView HOT 1
- setDragScale method in OnSwipe only accepts integer values
- [Compose] Multiple transitions onSwipe HOT 4
- [Compose] Layout not behaving as expected when using Dimension.fillToConstraints.atLeastWrapContent HOT 5
- I think this is definitely a bug HOT 6
- ConstraintLayoutReference.id is internal in alpha version
- MotionLayout produces incorrect animation
- Setting match_parent in a child causes display and stability problems in its descendant views
- Jetpack Compose Constraint Layout. Constraint in preview are shifted
- [Compose] MotionLayout cannot animate the circle angle and distance together HOT 2
- MotionLayout bug with Recyclerview ( setTransition programmatically and back, Recyclerview Scroll did not attach to MotionLayout OnSwipe )
- onSwipe not work when sub composable item with clickable Modifier
- Layer can't work with MotionLayout!
- MotionCompose Not Working with RememberSaveable
- App crashes when trying to animate fontSize in MotionScene for Compose
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from constraintlayout.