Specifies a view's position at a specific moment during the motion sequence. This attribute is used to adjust the default path of the motion.
For example, if an object begins at the upper left corner and ends at the lower
right corner, the default motion sequence would move the object in a straight
path diagonally down the screen. By adding one or more
you can deform the path.
<KeyPosition motion:motionTarget="@id/targetPath" motion:framePosition="percentage" motion:keyPositionType="type" motion:percentX="xOffset" motion:percentY="yOffset" />
- View whose motion is controlled by this
- Integer from 1 to 99 specifying when in the motion sequence the view reaches
the point specified by this
<KeyPosition>. For example, if
framePositionis 25, the view reaches the specified point a fourth of the way through the motion.
- Specify the position the view should reach. The
keyPositionTypeattribute specifies how these values are interpreted.
- Specifies how the
percentYvalues are interpreted. Possible settings are:
percentYare specified relative to the parent view. X is the horizontal axis, ranging from 0 (for the left side) to 1 (for the right side). Y is the vertical axis, with 0 being the top and 1 being the bottom.
For example, if you want the target view to reach a point midway down the right side of the parent view, you would set
percentXto 1 and
percentYare specified relative to the distance the view moves over the course of the whole motion sequence. X is the horizontal axis and Y is the vertical axis; in both cases, 0 is the starting position of the view in that axis, and 1 is the final position.
For example, suppose the target view moves 100 dp up and 100 dp to the right, but you want the view to begin by moving down 40 dp for the first quarter of the motion, then arc back up. To do this, set
The X axis is the direction the target view moves over the course of the path, with 0 being the beginning position and 1 being the final position. The Y axis is perpendicular to the X axis, with positive values being to the left of the path and negative values to the right; setting a non-zero percentY causes the view to arc to one direction or the other. So, the initial position of the view is
(0,0)and the final position is
For example, suppose you want the view to take half of the motion sequence to cover 10% of the total distance, then speed up to cover the other 90%. To do this, set
keyPositionTypeto pathRelative, and