<OnClick>
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
指定使用者輕觸檢視區塊時要執行的動作。您可以在
多個 <OnClick>
節點
<Transition>
,其中包含
每個 <OnClick>
,分別指定不同的目標檢視畫面和要執行的動作
就能執行相關動作
語法
<OnClick
motion:targetId="@id/target_view"
motion:clickAction="action"/>
屬性
motion:targetId
- 正在監控資料檢視。當使用者輕觸這個檢視畫面,系統就會轉場
會發生什麼事
motion:ClickAction
- 使用者輕觸檢視畫面時要執行的動作。支援的值為
包括:
transitionToStart
- 從目前的版面配置動畫,呈現
<Transition>
元素的
motion::constraintSetStart
屬性。
transitionToEnd
- 從目前的版面配置動畫,呈現
<Transition>
元素的
motion:constraintSetEnd
屬性。
jumpToStart
- 從目前的版面配置跳到
<Transition>
元素的
motion::constraintSetStart
屬性。
jumpToEnd
- 從目前的版面配置跳到
<Transition>
元素的
motion:constraintSetEnd
屬性。
toggle
- 如果版面配置處於起始狀態,請在結尾加入動畫。否則
加入動畫
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","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 (世界標準時間)。"],[],[],null,["# <OnClick>\n\nSpecifies the action to perform when the user taps on a view. There can be\nmultiple `\u003cOnClick\u003e` nodes for a single\n[`\u003cTransition\u003e`](/training/constraint-layout/motionlayout/ref/transition), with\neach `\u003cOnClick\u003e` specifying a different target view and a different action to\nperform when the view is tapped.\n\nSyntax\n------\n\n```xml\n\u003cOnClick\n motion:targetId=\"@id/target_view\"\n motion:clickAction=\"action\"/\u003e\n```\n\nAttributes\n----------\n\n`motion:targetId`\n: View being monitored. When the user taps this view, the transition\n occurs.\n\n`motion:ClickAction`\n: Action to perform when the view is tapped. Supported values are the\n following:"]]