Gemini 可在 Android Studio 中提供 AI 赋能的代码自动补全功能,该功能会在您输入内容时以灰色斜体文本的形式显示。此功能可建议完整的函数,从而节省您的时间,让您更快地完成编码项目。启用 AI 代码补全功能后,Gemini 可能会发送代码库中的其他信息(例如周围的代码片段、文件类型和其他必要信息)来为 LLM 提供上下文,从而提供更相关的建议。
[null,null,["最后更新时间 (UTC):2025-07-31。"],[],[],null,["# Accelerate coding with AI code completion\n\nGemini offers AI-enabled autocompletion of code in Android Studio that appears\nas gray italicized text as you type. This feature saves you time and lets you\ncomplete coding projects faster by suggesting full functions. When AI code\ncompletion is enabled, Gemini might send additional information from your\ncodebase such as surrounding pieces of your code, file types, and other\nnecessary information to provide context to the LLM and provide more relevant\nsuggestions.\n\nTo use AI code completion, follow these steps:\n\n1. Enable context sharing by selecting **Use all Gemini features** in the [Gemini settings](/studio/gemini/configure-gemini). AI code completion only works when Gemini can access context from your codebase.\n2. Open a file and start typing. Suggestions only trigger when the cursor is at the end of a line or anywhere on a blank line.\n3. Press \u003ckbd\u003eTab\u003c/kbd\u003e to accept a suggestion and \u003ckbd\u003eEsc\u003c/kbd\u003e to clear a suggestion.\n\nKeep in mind that the system won't always generate code completions. It's\npossible that the model doesn't have enough information to generate a response\nwith high confidence.\n\nYou can toggle AI code completion on and off at any time by clicking the Gemini\nicon at the bottom of the Studio IDE\n\nand clicking **Enable AI code completion**."]]