馃帹 Tworzenie widok贸w
use "android";
createView(type, props)
Typy widok贸w
| Typ | Android Widget | Opis |
"text" | TextView | Tekst |
"button" | Button | Przycisk |
"input" | EditText | Pole tekstowe |
"image" | ImageView | Obraz |
"switch" | Switch | Prze艂膮cznik |
"checkbox" | CheckBox | Checkbox |
"progress" | ProgressBar | Progress |
"column" | LinearLayout (V) | Uk艂ad pionowy |
"row" | LinearLayout (H) | Uk艂ad poziomy |
"scroll" | ScrollView | Scroll pionowy |
"card" | CardView | Karta |
"divider" | View | Linia oddzielaj膮ca |
"spacer" | Space | Odst臋p |
Wsp贸lne w艂a艣ciwo艣ci
{
width: 200,
height: 100,
padding: 16,
margin: 8,
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",
onTextChanged: fn(text) {
print("Wpisano: " + text);
}
});
Image
let img = createView("image", {
drawable: "my_image",
width: 100,
height: 100,
scaleType: "centerCrop"
});
let urlImg = createView("image", {
url: "https://example.com/image.png",
width: 200,
height: 200
});
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"}));