滑動以查看
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
允許使用者滑動元件,以便顯示其他動作。

「滑動即可顯示」元件可讓您為方塊和資訊卡新增額外動作,特別是方塊出現在清單中時。這個元件可讓使用者在不用離開畫面的情況下,快速完成工作。
使用者可以將部分方塊和資訊卡向左滑動,藉此執行這些動作,然後輕觸動作即可完成。使用者也可以將方塊和資訊卡完全向左滑動,快速前往主要動作。
元件有 2 個用於這些動作的版位:
- 主要
- 次要 (選填)
圖解
顯示的動作
開發人員可根據獨特用途自訂動作。請考慮在這些動作中使用的顏色和圖像,幫助使用者瞭解自己的意思。
已顯示的動作會顯示在所有語言語言代碼的同一側。
- 主要動作
- 次要動作 (選用)
持續執行主要動作
如要執行主要動作,使用者只要輕觸按鈕或繼續向左滑動即可。如此一來,按鈕就會延伸至整個螢幕寬度並顯示標籤。選取後,動作就會消失。
第一個範例顯示單一按鈕選項。第二個示例是雙按鈕選項,
復原動作
如果是破壞性動作,請新增復原元件,讓使用者復原這些動作。將復原功能新增至主要動作。
新增後,系統會改為顯示「復原方塊」按鈕,取代已提交的動作。復原動作不久後就會消失,且系統會完成承諾的動作。
滑動閾值
滑動顯示元件的行為,取決於使用者在畫面上滑動多少距離:
- 如果使用者在螢幕的 50% 以下的範圍內滑動,元件會彈回原本的位置,且不會執行任何動作。
- 如果使用者滑動畫面介於整個寬度的 50% 到 75% 之間,元件會保持部分顯示,並顯示與該元件相關聯的動作。
- 如果使用者滑動的螢幕寬度超過 75%,元件就會消失,且系統會自動執行主要動作。
下列材質主題元件會實作滑動顯示行為:
資訊卡顯示
以下螢幕截圖顯示使用 SwipeToRevealCard
類別時,滑動顯示元件外觀的滑動畫面:

如為方塊
以下螢幕截圖顯示使用 SwipeToRevealChip
類別時,滑動顯示元件外觀的滑動畫面:

這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Swipe to reveal\n\nAllow users to swipe a component to reveal extra actions.\n\nThe *swipe to reveal* component lets you add extra actions to\nchips and cards, specifically when they appear in lists. This component lets\nusers quickly get things done without leaving the screen.\n\nUsers can partially swipe chips and cards to the left to access these\nactions, then tap on an action to complete it. Users can also fully swipe\nchips and cards to the left to quickly commit to the primary action. \nThe component has 2 slots for these actions:\n\n1. **Primary**\n2. **Secondary (optional)**\n\nAnatomy\n-------\n\n### Revealed actions\n\nDevelopers can customize the actions for their unique use cases. Consider\nthe color and iconography used in these actions to help users understand\nwhat they mean.\n\nThe revealed actions appear on the same side for all language\nlocales.\n\n1. **Primary action**\n2. **Secondary action (optional)** \n\n### Commit to a primary action\n\nTo commit to the primary action, a user can either tap on the button or\ncontinue swiping to the left. In this way, the button extends to the entire\nwidth of the screen and displays a label. The action fades away after being\nselected.\n\nThe first example shows a **single button option** . The\nsecond example shows a **double button option**. \n\n### Undo action\n\nFor destructive actions, add an undo component to let users reverse these\nactions. Add the undo capability to the primary action.\n\nIf added, an undo chip button appears in place of the committed action.\nAfter a short period of time, the undo action fades away, and the system\ncompletes the committed action. \n\n### Swipe thresholds\n\nThe swipe to reveal component's behavior depends upon how far the user\nswipes across the screen:\n\n- If the user swipes across less than 50% of the screen, the component snaps back to its starting position, and no action is taken.\n- If the user swipes across the screen between 50% and 75% of the full width, the component remains partially visible, and the actions associated with the component appear.\n- If the user swipes across more than 75% of the screen, the component disappears, and the system automatically performs the primary action.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nRelated components\n------------------\n\nThe following material-themed components implement the swipe to reveal behavior:\n\n- [`SwipeToRevealCard`](/reference/kotlin/androidx/wear/compose/material/package-summary#SwipeToRevealCard(androidx.wear.compose.material.SwipeToRevealAction,androidx.wear.compose.foundation.RevealState,androidx.compose.ui.Modifier,androidx.wear.compose.material.SwipeToRevealAction,androidx.wear.compose.material.SwipeToRevealAction,androidx.wear.compose.material.SwipeToRevealAction,androidx.wear.compose.material.SwipeToRevealActionColors,androidx.compose.ui.graphics.Shape,kotlin.Function0))\n- [`SwipeToRevealChip`](/reference/kotlin/androidx/wear/compose/material/package-summary#SwipeToRevealChip(androidx.wear.compose.material.SwipeToRevealAction,androidx.wear.compose.foundation.RevealState,androidx.compose.ui.Modifier,androidx.wear.compose.material.SwipeToRevealAction,androidx.wear.compose.material.SwipeToRevealAction,androidx.wear.compose.material.SwipeToRevealAction,androidx.wear.compose.material.SwipeToRevealActionColors,androidx.compose.ui.graphics.Shape,kotlin.Function0))\n\n### On cards\n\nThe following screenshots show the swipe to reveal component's appearance when\nusing the `SwipeToRevealCard` class:\n\n### On chips\n\nThe following screenshots show the swipe to reveal component's appearance when\nusing the `SwipeToRevealChip` class:"]]