ui/layout
Resource IDs (R), default themed Context, and XML inflation helpers for building native View trees from layout strings.
Table of contents
Interfaces
Constants
Functions
Constants
R
R:Resources
Like Android’s generated R: holds numeric IDs for drawables, styles, and other packaged resources, e.g. R.drawable.ic_launcher, R.style.ScriptTheme.
Example
"nodejs";
const { R } = require("ui");
const context = $autojs.androidContext;
console.log(context.getDrawable(R.drawable.ic_delete));See also
Functions
defaultThemeContext
defaultThemeContext(): Context
Returns a Context suitable for inflating UI with the default script / Material theme (use this when you need a themed context for inflateXml or AndroidX widgets).
Returns
Context
inflateXml
inflateXml(ctx: Context, xml: string, parent?: any, attachToParent?: boolean): JsView<View>
Parses the XML layout string and builds the corresponding View hierarchy. On failure, throws InflateException.
Parameters
| Name | Type | Description |
|---|---|---|
ctx | Context | Android Context used for inflation. For AndroidX / Material views, pass a Material-themed context (often defaultThemeContext). |
xml | string | Layout XML as a string. |
parent? | any | Optional parent ViewGroup: supplies LayoutParams while inflating. If you do not attach the result to this parent, it is still used as the root for measurement when non-null. |
attachToParent? | boolean | If true, the inflated view is added to parent. Default false. |
Returns
JsView<View>
Wrapper around the inflated Android View root (see ui_view for JsView usage).
