Specifies the action to perform when the user swipes on the layout. The speed of the motion sequence and the motion of the targeted view are affected by the speed and direction of the swipe, subject to the limits you set with optional parameters.
There can be multiple
<OnSwipe> nodes for a single
<Transition>, with each
<OnSwipe> specifying a different swipe direction and a different action to
perform when the user performs that swipe.
<OnSwipe motion:touchAnchorId="@id/target_view" motion:touchAnchorSide="side" [ motion:dragDirection="direction" ] [ motion:dragScale="scale" ] [ motion:maxVelocity="maxVelocity" ] [ motion:maxAcceleration="maxAcceleration" ] />
- View that is being moved by the swipe.
- Side of the target view that the swipe is anchored to.
MotionLayoutkeeps a constant distance between the anchor and the user's finger. Acceptable values are
- Direction of the user's swipe motion. If this attribute is set, this
<OnSwipe>only applies to swipes in the specified direction. Acceptable values are
Controls the distance the view moves relative to the length of the swipe. The default value is 1, indicating that the view moves as far as the swipe does. If
dragScaleis less than 1, the view moves less than the swipe distance. For example, a
dragScaleof 0.5 means that if the swipe moves 4 cm, the target view moves 2 cm.
dragScaleis greater than 1, the view moves farther than the swipe distance. For example, a
dragScaleof 1.5 means that if the swipe moves 4 cm, the target view moves 6 cm.
Maximum velocity of the target view.
Maximum acceleration of the target view.