Documentation Index Fetch the complete documentation index at: https://mintlify.com/AndroidCSOfficial/android-code-studio/llms.txt
Use this file to discover all available pages before exploring further.
Android Code Studio provides comprehensive XML language support specifically tailored for Android development, including smart completions for layouts, manifests, and resource files.
Language Server Features
The XML Language Server (XMLLanguageServer) offers specialized support for Android XML files:
Context-Aware Completion Intelligent suggestions based on file type (layout, manifest, drawable, etc.)
Android Attributes Complete android: namespace attributes with value suggestions
Resource References Auto-complete @string, @drawable, @color, and other resource references
Code Formatting Automatic XML formatting with configurable indentation and line breaks
File Type Support
The XML LSP recognizes and provides specialized completion for different Android XML file types:
Layout Files
Layout files in res/layout/ receive specialized completion:
Implementation: Layout completion is handled by LayoutTagCompletionProvider and LayoutAttrCompletionProvider (source: xml/lsp/src/main/java/com/tom/rv2ide/lsp/xml/providers/completion/layout/)
AndroidManifest.xml
Specialized completion for manifest elements:
<? xml version = "1.0" encoding = "utf-8" ?>
< manifest xmlns:android = "http://schemas.android.com/apk/res/android"
package = "com.example.myapp" >
<!-- Type 'uses-' for permission declarations -->
< uses-permission android:name = "android.permission.INTERNET" />
< uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" />
< application
android:allowBackup = "true"
android:icon = "@mipmap/ic_launcher"
android:label = "@string/app_name"
android:theme = "@style/AppTheme" >
<!-- Type 'activity' for activity declaration -->
< activity
android:name = ".MainActivity"
android:exported = "true" >
< intent-filter >
<!-- Type 'action' for intent actions -->
< action android:name = "android.intent.action.MAIN" />
<!-- Type 'category' for intent categories -->
< category android:name = "android.intent.category.LAUNCHER" />
</ intent-filter >
</ activity >
<!-- Type 'service' for service declaration -->
< service
android:name = ".MyService"
android:enabled = "true"
android:exported = "false" />
</ application >
</ manifest >
Implementation: Manifest completion uses ManifestTagCompletionProvider, ManifestAttrCompletionProvider, and ManifestAttrValueCompletionProvider
Drawable XML Files
Completion for drawable resources (res/drawable/):
Shape Drawables
Layer List
Vector Drawables
<? xml version = "1.0" encoding = "utf-8" ?>
< shape xmlns:android = "http://schemas.android.com/apk/res/android"
android:shape = "rectangle" >
<!-- Type 'solid' for solid color -->
< solid android:color = "@color/primary" />
<!-- Type 'corners' for rounded corners -->
< corners android:radius = "8dp" />
<!-- Type 'stroke' for border -->
< stroke
android:width = "2dp"
android:color = "@color/primary_dark" />
</ shape >
<? xml version = "1.0" encoding = "utf-8" ?>
< layer-list xmlns:android = "http://schemas.android.com/apk/res/android" >
<!-- Shadow layer -->
< item
android:left = "2dp"
android:top = "2dp" >
< shape android:shape = "rectangle" >
< solid android:color = "#40000000" />
< corners android:radius = "4dp" />
</ shape >
</ item >
<!-- Main layer -->
< item >
< shape android:shape = "rectangle" >
< solid android:color = "@android:color/white" />
< corners android:radius = "4dp" />
</ shape >
</ item >
</ layer-list >
<? xml version = "1.0" encoding = "utf-8" ?>
< vector xmlns:android = "http://schemas.android.com/apk/res/android"
android:width = "24dp"
android:height = "24dp"
android:viewportWidth = "24"
android:viewportHeight = "24" >
<!-- Type 'path' for vector path -->
< path
android:fillColor = "@color/accent"
android:pathData = "M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z" />
</ vector >
Implementation: Drawable completion uses DrawableTagTransformer to provide context-specific suggestions
Animation Files
Support for animation XML files:
View Animations
Object Animators
<? xml version = "1.0" encoding = "utf-8" ?>
< set xmlns:android = "http://schemas.android.com/apk/res/android" >
<!-- Type 'alpha' for alpha animation -->
< alpha
android:fromAlpha = "0.0"
android:toAlpha = "1.0"
android:duration = "300" />
<!-- Type 'scale' for scale animation -->
< scale
android:fromXScale = "0.8"
android:toXScale = "1.0"
android:fromYScale = "0.8"
android:toYScale = "1.0"
android:pivotX = "50%"
android:pivotY = "50%"
android:duration = "300" />
</ set >
<? xml version = "1.0" encoding = "utf-8" ?>
< set xmlns:android = "http://schemas.android.com/apk/res/android"
android:ordering = "together" >
<!-- Type 'objectAnimator' -->
< objectAnimator
android:propertyName = "translationY"
android:valueFrom = "1000"
android:valueTo = "0"
android:duration = "500"
android:interpolator = "@android:interpolator/decelerate_quad" />
</ set >
Implementation: Animation files use AnimTagTransformer and AnimatorTagTransformer for type-specific completion
Completion for menu resources:
<? xml version = "1.0" encoding = "utf-8" ?>
< menu xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:app = "http://schemas.android.com/apk/res-auto" >
<!-- Type 'item' for menu item -->
< item
android:id = "@+id/action_search"
android:icon = "@drawable/ic_search"
android:title = "@string/action_search"
app:showAsAction = "ifRoom" />
< item
android:id = "@+id/action_settings"
android:title = "@string/action_settings"
app:showAsAction = "never" />
</ menu >
Implementation: Menu completion provided by MenuTagTransformer
Completion Providers
The XML LSP uses a provider pattern for different completion contexts:
Tag Completion
Provides suggestions for XML element names:
LayoutTagCompletionProvider : Android View classes
ManifestTagCompletionProvider : Manifest elements (activity, service, receiver, etc.)
SimpleTagCompleter : Simple tag name completion
QualifiedTagCompleter : Fully qualified class names
Attribute Completion
Suggests available attributes for a given element:
LayoutAttrCompletionProvider : View attributes
ManifestAttrCompletionProvider : Manifest attributes
CommonAttrCompletionProvider : Common XML attributes
InheritingAttrCompletionProvider : Attributes inherited from parent tags
Attribute Value Completion
Provides value suggestions for attributes:
AttrValueCompletionProvider : Resource references, enum values, booleans
ManifestAttrValueCompletionProvider : Manifest-specific values (permissions, features, etc.)
The XML formatter (CodeFormatProvider) provides automatic formatting:
class XMLFormattingOptions {
var tabSize: Int = 4
var insertSpaces: Boolean = true
var splitAttributes: Boolean = false
var closingTagBracketOnNewLine: Boolean = false
}
< LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "match_parent" android:layout_height = "match_parent" android:orientation = "vertical" >< TextView android:id = "@+id/textView" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "Hello" /></ LinearLayout >
< LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:orientation = "vertical" >
< TextView
android:id = "@+id/textView"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "Hello" />
</ LinearLayout >
Implementation: The formatter uses multiple specialized classes:
XMLFormatter: Main formatting coordinator
DOMElementFormatter: Element formatting logic
DOMAttributeFormatter: Attribute alignment
DOMTextFormatter: Text content formatting
Advanced Editing Features
The AdvancedEditProvider handles automatic tag closing:
<!-- Type '<TextView' and '>' -->
< TextView >
<!-- Automatically inserts closing tag -->
</ TextView >
Attribute Quotes
Automatic quote insertion for attribute values:
<!-- Type 'android:text=' -->
android:text=""
<!-- Cursor positioned inside quotes -->
Resource Reference Completion
Type @ to trigger resource reference completion:
@string/ - String resources
@drawable/ - Drawable resources
@color/ - Color resources
@dimen/ - Dimension resources
@style/ - Style resources
@id/ - View IDs
@+id/ - Define new ID
@android: - Android framework resources
XML Parsing
The XML LSP uses Eclipse LemMinX DOM parser for robust XML parsing:
val document = DOMParser. getInstance (). parse (
contents,
"http://schemas.android.com/apk/res/android" ,
URIResolverExtensionManager ()
)
The parser provides:
Error Recovery : Continue parsing despite syntax errors
Node Location : Accurate position information for completions
Namespace Support : Handle android:, app:, and tools: namespaces
Node Type Detection
The completion system detects context using XmlUtils.getNodeType():
enum class NodeType {
TAG, // Inside element name: <TextVi|w>
ATTRIBUTE, // Inside attribute name: android:lay|
ATTRIBUTE_VALUE, // Inside attribute value: android:text="|"
UNKNOWN // Cannot determine context
}
Configuration
Server Settings
object XMLServerSettings : IServerSettings {
override fun completionsEnabled (): Boolean = true
override fun codeActionsEnabled (): Boolean = true
}
Custom Settings
Apply custom settings to the XML server:
val customSettings = object : IServerSettings {
override fun completionsEnabled () = true
override fun codeActionsEnabled () = false
}
xmlServer. applySettings (customSettings)
Caching
The XML LSP caches parsed documents to improve performance:
Parse Cache : Stores DOM trees for recently accessed files
Resource Cache : Caches available resources from R class
Attribute Cache : Stores attribute definitions for view types
Prefix Matching
Completion is triggered only when a meaningful prefix is typed:
val prefix = XmlUtils. getPrefix (document, cursorPosition, nodeType)
if (prefix. isBlank () && type != ATTRIBUTE_VALUE) {
return EMPTY // Don't show completions
}
Limitations
Current limitations of the XML language server:
Custom View Attributes : Attributes from custom views may not be suggested unless properly documented
Data Binding : Limited completion for data binding expressions inside @{}
Constraint Layout : Some ConstraintLayout-specific attributes may have incomplete suggestions
Multi-module Resources : Resources from library modules may not always be available
Troubleshooting
Completion Not Working
If XML completion stops working:
Check the file is in a recognized directory (res/layout/, res/drawable/, etc.)
Ensure the XML file has a valid XML declaration
Verify the namespace declarations are correct
Check that the project has been synced
If formatting produces unexpected results:
Check for unclosed tags in the XML
Verify the XML is well-formed (balanced tags)
Adjust formatting options in settings
Resource References Not Completing
If @string/ and other resource references don’t complete:
Ensure resources are defined in appropriate XML files
Check that the R class has been generated (build the project)
Verify the module dependencies include the resources
API Reference
XMLLanguageServer
Main server interface:
class XMLLanguageServer : ILanguageServer {
override val serverId: String = "ide.lsp.xml"
override fun complete (params: CompletionParams ?): CompletionResult
override fun formatCode (params: FormatCodeParams ?): CodeFormatResult
override suspend fun analyze (file: Path ): DiagnosticResult
}
XmlCompletionProvider
Completion implementation:
class XmlCompletionProvider (settings: IServerSettings ) : ICompletionProvider {
override fun complete (params: CompletionParams ): CompletionResult {
val document = DOMParser. getInstance (). parse (contents, .. .)
val type = XmlUtils. getNodeType (document, cursorPosition)
val completer = getCompleter (pathData, type)
return completer. complete (params, pathData, document, type, prefix)
}
}
Formatting implementation:
class CodeFormatProvider {
fun format (params: FormatCodeParams ?): CodeFormatResult {
val formatter = XMLFormatter ()
val edits = formatter. format (document, options)
return CodeFormatResult (isFormatted = true , edits = edits)
}
}
Java Support Learn about Java language features
Kotlin Support Explore Kotlin language capabilities
Project Management Manage Android resources and projects
UI Designer Visual layout editor