<OnSlide>
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מציינת את הפעולה שתתבצע כשהמשתמש מחליק על הפריסה. המהירות של
רצף התנועה והתנועה של התצוגה המטורגטת מושפעים
המהירות והכיוון של ההחלקה, בכפוף למגבלות שהגדרת
.
בכל <Transition>
יכולים להיות כמה צמתים מסוג <OnSwipe>
, בכל אחד מהם
<OnSwipe>
שמציין כיוון החלקה שונה ופעולה שונה
ביצועים כשהמשתמש מבצע את ההחלקה.
תחביר
<OnSwipe
motion:touchAnchorId="@id/target_view"
motion:touchAnchorSide="side"
[ motion:dragDirection="direction" ]
[ motion:dragScale="scale" ]
[ motion:maxVelocity="maxVelocity" ]
[ motion:maxAcceleration="maxAcceleration" ]
/>
מאפיינים
motion:touchAnchorId
- הצגת שמוזזת על ידי ההחלקה.
motion:touchAnchorSide
- בצד של תצוגת היעד שההחלקה מעוגנת אליה.
MotionLayout
שומר
במרחק קבוע בין העוגן לאצבע של המשתמש. ערכים קבילים
הם "left"
, "right"
, "top"
ו-"bottom"
.
motion:dragDirection
- כיוון תנועת ההחלקה של המשתמש. אם המאפיין הזה מוגדר,
<OnSwipe>
חל רק על החלקות בכיוון שצוין. ערכים קבילים
הם "dragLeft"
, "dragRight"
, "dragUp"
ו-"dragDown"
.
motion:dragScale
שליטה על המרחק שהתצוגה נעה ביחס לאורך ההחלקה.
ערך ברירת המחדל הוא 1, שמציין שהתצוגה זזה בהתאם למיקום ההחלקה.
אם הערך של dragScale
קטן מ-1, התצוגה תזיז פחות ממרחק ההחלקה.
לדוגמה, ערך dragScale
של 0.5 מציין שאם ההחלקה זזה בטווח של 4 ס"מ,
תצוגת היעד זזה בטווח של 2 ס"מ.
אם הערך של dragScale
גדול מ-1, התצוגה זזה רחוק יותר מפעולת ההחלקה
מרחק. לדוגמה, ערך dragScale
של 1.5 מציין שאם ההחלקה עוברת 4
ס"מ, תצוגת היעד נעה ב-6 ס"מ.
motion:maxVelocity
המהירות המקסימלית של תצוגת היעד.
motion:maxAcceleration
האצה מקסימלית של תצוגת היעד.
בתוך
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-27 (שעון UTC)."],[],[],null,["# <OnSwipe>\n\nSpecifies the action to perform when the user swipes on the layout. The speed of\nthe motion sequence and the motion of the targeted view are affected by the\nspeed and direction of the swipe, subject to the limits you set with optional\nparameters.\n\nThere can be multiple `\u003cOnSwipe\u003e` nodes for a single `\u003cTransition\u003e`, with each\n`\u003cOnSwipe\u003e` specifying a different swipe direction and a different action to\nperform when the user performs that swipe.\n\nSyntax\n------\n\n```xml\n\u003cOnSwipe\n motion:touchAnchorId=\"@id/target_view\"\n motion:touchAnchorSide=\"side\"\n[ motion:dragDirection=\"direction\" ]\n[ motion:dragScale=\"scale\" ]\n[ motion:maxVelocity=\"maxVelocity\" ]\n[ motion:maxAcceleration=\"maxAcceleration\" ]\n /\u003e\n```\n\nAttributes\n----------\n\n`motion:touchAnchorId`\n: View that is being moved by the swipe.\n\n`motion:touchAnchorSide`\n: Side of the target view that the swipe is anchored to. `MotionLayout` keeps a\n constant distance between the anchor and the user's finger. Acceptable values\n are `\"left\"`, `\"right\"`, `\"top\"`, and `\"bottom\"`.\n\n`motion:dragDirection`\n: Direction of the user's swipe motion. If this attribute is set, this\n `\u003cOnSwipe\u003e` only applies to swipes in the specified direction. Acceptable values\n are `\"dragLeft\"`, `\"dragRight\"`, `\"dragUp\"`, and `\"dragDown\"`.\n\n`motion:dragScale`\n\n: Controls the distance the view moves relative to the length of the swipe. The\n default value is 1, indicating that the view moves as far as the swipe does.\n If `dragScale` is less than 1, the view moves less than the swipe distance.\n For example, a `dragScale` of 0.5 means that if the swipe moves 4 cm, the\n target view moves 2 cm.\n\n If `dragScale` is greater than 1, the view moves farther than the swipe\n distance. For example, a `dragScale` of 1.5 means that if the swipe moves 4\n cm, the target view moves 6 cm.\n\n`motion:maxVelocity`\n\n: Maximum velocity of the target view.\n\n`motion:maxAcceleration`\n\n: Maximum acceleration of the target view.\n\nContained in\n------------\n\n- [`\u003cTransition\u003e`](/training/constraint-layout/motionlayout/ref/transition)"]]