כתיבה ידנית בסטיילוס מופעלת כברירת מחדל בכל רכיבי TextField
Android מגרסה 14 ואילך
androidx.compose.foundation:foundation:1.7.0
של יחסי התלות. מצב כתב היד מופעל עם TextField בתנועת סטיילוס
האירוע מזוהה בגבולות כתב היד של הרכיב.
הגבולות של כתב היד כוללים מרווח פנימי של 40dp ורוחב של 10dp
המרווח הפנימי סביב שדה הקלט.
איור 2. גבולות כתב יד של רכיבי TextField.
אין תמיכה בכתיבה ידנית בסטיילוס בשדות TextField כששיטת הקלט
נשלחה בקשת עריכה באמצעות KeyboardType.Password.
הענקת גישה לקלט
אפליקציות יכולות להציג רכיבי placeholder בממשק המשתמש שנראים כמו שדות של קלט טקסט,
הם למעשה רכיבים סטטיים בממשק המשתמש, ללא יכולת של קלט טקסט. קמפיינים לרשת החיפוש
הם דוגמה נפוצה לשדות. הקשה על הרכיב הסטטי של ממשק המשתמש מפעילה מעבר
לממשק משתמש חדש שמכיל שדה פונקציונלי להזנת קלט, שמתמקד בקלט.
איור 3. יש להזין את הקצאת הגישה מהרכיב הסטטי של ממשק המשתמש לשדה להזנת קלט טקסט.
הרשאת גישה לקלט סטיילוס
שימוש בממשקי ה-API להאצלת כתב יד כדי לתמוך בקלט כתב יד בסטיילוס
בשדות להזנת קלט placeholder (ראו handwritingDetectorhandwritingHandler). רכיב ה-placeholder של ממשק המשתמש הוא
מוגדרת להאציל את כתב היד לשדה פונקציונלי להזנת קלט. לדוגמה
להטמעה, ראה
HandwritingDetectorSample.kt
מצב כתב יד בסטיילוס מתחיל כששדה הקלט הפונקציונלי מקבל מיקוד
יוצרת
InputConnection
איור 4. הענקת גישה לקלט סטיילוס מרכיב בממשק משתמש סטטי לשדה להזנת טקסט.
בדיקה
כתיבה ידנית בסטיילוס נתמכת במכשירים עם Android מגרסה 14 ואילך עם
מכשיר תואם לקלט סטיילוס ושיטת קלט
עורך (IME)
תומך בממשקי API לכתיבה ידנית בסטיילוס ב-Android 14.
אם אין לך מכשיר לקלט סטיילוס, עליך לדמות קלט סטיילוס בכל מכשיר
עם גישה לרמה הבסיסית (root) (כולל אמולטורים) באמצעות הגשר הבא לניפוי באגים ב-Android
פקודות (adb):
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. 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,["# Stylus input in text fields\n\nThe Jetpack\n[`androidx.compose.material3`](/jetpack/androidx/releases/compose-material3)\nlibrary enables users to write into any [`TextField`](/reference/kotlin/androidx/compose/material/package-summary#TextField(androidx.compose.ui.text.input.TextFieldValue,kotlin.Function1,androidx.compose.ui.Modifier,kotlin.Boolean,kotlin.Boolean,androidx.compose.ui.text.TextStyle,kotlin.Function0,kotlin.Function0,kotlin.Function0,kotlin.Function0,kotlin.Boolean,androidx.compose.ui.text.input.VisualTransformation,androidx.compose.foundation.text.KeyboardOptions,androidx.compose.foundation.text.KeyboardActions,kotlin.Boolean,kotlin.Int,kotlin.Int,androidx.compose.foundation.interaction.MutableInteractionSource,androidx.compose.ui.graphics.Shape,androidx.compose.material.TextFieldColors)) component in\nany app using a stylus.\nYour browser doesn't support the video tag. **Figure 1.** Handwritten input with a stylus.\n\nTo enable stylus input by default, add the library dependency to your app's\n`build.gradle` file: \n\n### Kotlin\n\n```kotlin\ndependencies {\n implementation(\"androidx.compose.foundation:foundation:\u003cvar translate=\"no\"\u003eLATEST_COMPOSE_VERSION\u003c/var\u003e\")\n}\n\nandroid {\n buildFeatures {\n compose = true\n }\n\n composeOptions {\n kotlinCompilerExtensionVersion = \"\u003cvar translate=\"no\"\u003eLATEST_EXTENSION_VERSION\u003c/var\u003e\"\n }\n\n kotlinOptions {\n jvmTarget = \"\u003cvar translate=\"no\"\u003eLATEST_JVM_VERSION\u003c/var\u003e\"\n }\n}\n```\n\n### Groovy\n\n```groovy\ndependencies {\n implementation 'androidx.compose.foundation:foundation:\u003cvar translate=\"no\"\u003eLATEST_COMPOSE_VERSION\u003c/var\u003e'\n}\n\nandroid {\n buildFeatures {\n compose true\n }\n\n composeOptions {\n kotlinCompilerExtensionVersion = '\u003cvar translate=\"no\"\u003eLATEST_EXTENSION_VERSION\u003c/var\u003e'\n }\n\n kotlinOptions {\n jvmTarget = '\u003cvar translate=\"no\"\u003eLATEST_JVM_VERSION\u003c/var\u003e'\n }\n}\n```\n\n`TextField`\n-----------\n\nStylus handwriting is enabled for all `TextField` components by default on\nAndroid 14 and higher and the\n[`androidx.compose.foundation:foundation:1.7.0`](/jetpack/androidx/releases/compose-foundation)\ndependency. Handwriting mode is started for a `TextField` when a stylus motion\nevent is detected within the handwriting bounds of the component.\n\nThe handwriting bounds include 40 dp of vertical padding and 10 dp of horizontal\npadding around the input field.\n**Figure 2.** Handwriting bounds of `TextField` components.\n\nStylus handwriting is not supported for `TextField` fields when the input method\neditor is requested with [`KeyboardType.Password`](/reference/kotlin/androidx/compose/ui/text/input/KeyboardType#Password()).\n\nInput delegation\n----------------\n\nApps can display placeholder UI elements that appear to be text input fields but\nare actually just static UI elements with no text input capability. Search\nfields are a common example. Tapping the static UI element triggers a transition\nto a new UI that contains a functional text input field focused for input.\nYour browser doesn't support the video tag. **Figure 3.** Input delegation from static UI element to text input field.\n\n### Stylus input delegation\n\nUse the handwriting delegation APIs to support stylus handwriting input for\nplaceholder input fields (see [`handwritingDetector`](/reference/kotlin/androidx/compose/foundation/text/handwriting/package-summary#(androidx.compose.ui.Modifier).handwritingDetector(kotlin.Function0)) and\n[`handwritingHandler`](/reference/kotlin/androidx/compose/foundation/text/handwriting/package-summary#(androidx.compose.ui.Modifier).handwritingHandler())). The placeholder UI element is\nconfigured to delegate handwriting to a functional input field. For an example\nimplementation, see\n[`HandwritingDetectorSample.kt`](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/HandwritingDetectorSample.kt).\n\nStylus handwriting mode starts when the functional input field gains focus and\ncreates an\n[`InputConnection`](/reference/kotlin/android/view/inputmethod/InputConnection).\nYour browser doesn't support the video tag. **Figure 4.** Stylus input delegation from static UI element to text input field.\n\nTesting\n-------\n\nStylus handwriting is supported on Android 14 and higher devices with a\ncompatible stylus input device and an [input method\neditor](/develop/ui/views/touch-and-input/creating-input-method) (IME) that\nsupports the Android 14 stylus handwriting APIs.\n\nIf you don't have a stylus input device, simulate stylus input on any device\nwith root access (including emulators) using the following Android Debug Bridge\n(adb) commands: \n\n\n // Android 14\n adb shell setprop persist.debug.input.simulate_stylus_with_touch true && adb shell stop && adb shell start\n\n // Android 15 and higher\n // Property takes effect after screen reconfiguration such as orientation change.\n adb shell setprop debug.input.simulate_stylus_with_touch true\n\nUse the Gboard beta for testing if you are using a device that doesn't support\nstylus.\n\nAdditional resources\n--------------------\n\n- Material Design --- [Text fields](https://m3.material.io/components/text-fields/overview)\n- [Handle user input](/develop/ui/compose/text/user-input)"]]