處理鍵盤輸入
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
試試 Compose 的方式
Jetpack Compose 是 Android 推薦的 UI 工具包。瞭解 Compose 中的觸控和輸入方式。
當 UI 中的文字欄位獲得焦點時,Android 系統會顯示螢幕鍵盤 (稱為「軟體輸入法」)。為了提供最佳使用者體驗,您可以指定預期輸入類型 (例如電話號碼或電子郵件地址) 的特性,以及輸入方式的行為方式 (例如針對拼字錯誤執行自動修正)。
除了螢幕上的輸入方式,Android 也支援硬體鍵盤,因此請務必將應用程式最佳化,以支援連接的鍵盤。
下列說明文件將討論這些主題和其他內容。
課程
- 指定輸入法類型
- 瞭解如何顯示特定軟體輸入法,例如電話號碼、網址或其他格式的輸入法。此外,您還可以瞭解如何指定拼字建議行為和動作按鈕 (例如「完成」或「下一步」) 等特性。
- 處理輸入法顯示設定
- 瞭解如何指定軟體輸入法顯示的時機,以及版面配置如何調整以配合縮減的螢幕空間。
- 支援鍵盤導覽功能
- 瞭解如何確認使用者可以使用鍵盤瀏覽應用程式,以及如何對導覽順序進行必要的變更。
- 處理鍵盤動作
- 瞭解如何直接回應使用者動作的鍵盤輸入內容。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[[["容易理解","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-26 (世界標準時間)。"],[],[],null,["# Handle keyboard input\n\nTry the Compose way \nJetpack Compose is the recommended UI toolkit for Android. Learn about touch and input in Compose. \n[Touch and input →](/develop/ui/compose/touch-input) \n\nThe Android system shows an on-screen keyboard---known as a\n*soft input method*---when a text field in your UI receives focus.\nTo provide the best user experience, you can specify characteristics\nabout the type of input you expect, such as a\nphone number or email address, and how the input method must behave, such as\nperforming autocorrect for spelling mistakes.\n\nIn addition to the on-screen input methods, Android supports hardware keyboards, so it's\nalso important to optimize your app to support attached keyboards.\n\nThese topics and more are discussed in the following documentation.\n\nLessons\n-------\n\n**[Specify the input method type](/develop/ui/views/touch-and-input/keyboard-input/style)**\n: Learn how to show certain soft input methods, such as those designed for phone numbers, web\n addresses, or other formats. Also, learn how to specify characteristics such\n as spelling suggestion behavior and action buttons such as **Done** or **Next**.\n\n**[Handle input method visibility](/develop/ui/views/touch-and-input/keyboard-input/visibility)**\n: Learn how to specify when to show the soft input method and how\n your layout must adjust to the reduced screen space.\n\n**[Support keyboard navigation](/develop/ui/views/touch-and-input/keyboard-input/navigation)**\n: Learn how to verify that users can navigate your app using a keyboard\n and how to make any necessary changes to the navigation order.\n\n**[Handle keyboard actions](/develop/ui/views/touch-and-input/keyboard-input/commands)**\n: Learn how to respond directly to keyboard input for user actions."]]