馃帹 Tworzenie widok贸w

use "android";

createView(type, props)

Typy widok贸w

TypAndroid WidgetOpis
"text"TextViewTekst
"button"ButtonPrzycisk
"input"EditTextPole tekstowe
"image"ImageViewObraz
"switch"SwitchPrze艂膮cznik
"checkbox"CheckBoxCheckbox
"progress"ProgressBarProgress
"column"LinearLayout (V)Uk艂ad pionowy
"row"LinearLayout (H)Uk艂ad poziomy
"scroll"ScrollViewScroll pionowy
"card"CardViewKarta
"divider"ViewLinia oddzielaj膮ca
"spacer"SpaceOdst臋p

Wsp贸lne w艂a艣ciwo艣ci

{ width: 200, // dp lub "match"/"wrap" height: 100, // dp lub "match"/"wrap" padding: 16, // dp margin: 8, // dp backgroundColor: "#FF0000", alpha: 0.8, visible: true, enabled: true }

Przyk艂ady

Text

let text = createView("text", { text: "Nag艂贸wek", textSize: 24, textColor: "#6200EE", bold: true, italic: false, gravity: "center" });

Button

let btn = createView("button", { text: "Kliknij", backgroundColor: "#6200EE", textColor: "#FFFFFF", onClick: fn() { toast("Klikni臋to!"); } });

Input

let input = createView("input", { hint: "Wpisz email...", inputType: "email", // number, password, multiline onTextChanged: fn(text) { print("Wpisano: " + text); } });

Image

// Z drawable let img = createView("image", { drawable: "my_image", width: 100, height: 100, scaleType: "centerCrop" }); // Z URL let urlImg = createView("image", { url: "https://example.com/image.png", width: 200, height: 200 }); // Z mipmap let icon = createView("image", { mipmap: "ic_launcher" });

Layouts

let column = createView("column", { padding: 16, gravity: "center" }); let row = createView("row", { gravity: "center_vertical" }); addViewTo(column, createView("text", {text: "Item 1"})); addViewTo(column, createView("text", {text: "Item 2"}));