AIWROKÆ»¹û²¿·Ö¹¦ÄÜUI-ˮƽÈÝÆ÷[Horizontal]·½·¨Ð¡½á
- //🍎UI-ˮƽÈÝÆ÷[Horizontal]·½·¨Ð¡½á£¬½»Á÷QQȺ711841924
- //µÚÒ»¸ö·½·¨£º📌addViewÌí¼Ó×ӿؼþ
- var h = new Horizontal();
- var btn = new Button();
- h.addView(btn);
- //µÚ¶þ¸ö·½·¨£º📌removeViewÒÆ³ýÊÓͼ
- var h = new Horizontal();
- h.removeView(0); // ÒÆ³ýµÚÒ»¸ö×ӿؼþ
- //µÚÈý¸ö·½·¨£º📌clearAllViewsÇå¿ÕËùÓÐÊÓͼ
- var h = new Horizontal();
- h.clearAllViews(); // Çå¿ÕËùÓпؼþ
- //µÚËĸö·½·¨£º📌getViewCount »ñÈ¡ÊÓͼÊýÁ¿
- var h = new Horizontal();
- int count = h.getViewCount(); // »ñÈ¡×ӿؼþµÄÊýÁ¿
- //µÚÎå¸ö·½·¨£º📌setSpacingÉèÖÿؼþ¼ä¾à
- var h = new Horizontal();
- h.setSpacing(10); // ÉèÖÿؼþ¼ä¾àΪ10
- //µÚÁù¸ö·½·¨£º📌setBackgroundColorÉèÖñ³¾°ÑÕÉ«
- var h = new Horizontal();
- h.setBackgroundColor(50,100, 150); // ÉèÖñ³¾°ÑÕɫΪºìÉ«
- //µÚÆß¸ö·½·¨£º📌setAlignment ÉèÖÃ¶ÔÆë·½Ê½
- var h = new Horizontal();
- h.setAlignment("center"); // ÉèÖÃ¶ÔÆë·½Ê½Îª¾ÓÖÐ
- /*
- ¿ÉѡֵÈçÏ£º
- - fill: Ìî³ä¶ÔÆë
- - left: ×ó¶ÔÆë
- - right: ÓÒ¶ÔÆë
- - top: ¶¥²¿¶ÔÆë
- - bottom: µ×²¿¶ÔÆë
- - center: ¾ÓÖÐ¶ÔÆë
- ĬÈÏֵΪ fill¡£
- */
¸´ÖÆ´úÂë📌addViewÌí¼Ó×ӿؼþ Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÏòÈÝÆ÷ÖÐÌí¼ÓÒ»¸ö×ӿؼþ£¬¶à¸ö¿Ø¼þ»áÅÅÁе½Ò»Ðе±ÖÐ | ·½·¨Ç©Ãû | Void addView(Object view) | ·µ»ØÖµ | Void | ²ÎÊý | - Object view £ºÒªÌí¼ÓµÄ×ӿؼþ¶ÔÏó | °¸Àý | var h = new Horizontal(); var btn = new Button(); h.addView(btn); |
📌removeViewÒÆ³ýÊÓͼ Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ¸ù¾ÝÖ¸¶¨Ë÷ÒýÒÆ³ýÈÝÆ÷ÖеÄ×ӿؼþ | ·½·¨Ç©Ãû | Void removeView(Int32 index) | ·µ»ØÖµ | Void | ²ÎÊý | - Int32 index £ºÒªÒƳýµÄ×ӿؼþµÄË÷Òý£¨´Ó 0 ¿ªÊ¼¼ÆÊý£© | °¸Àý | var h = new Horizontal(); h.removeView(0); // ÒÆ³ýµÚÒ»¸ö×ӿؼþ |
📌clearAllViewsÇå¿ÕËùÓÐÊÓͼ Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÒÆ³ýÈÝÆ÷ÖеÄËùÓÐ×ӿؼþ | ·½·¨Ç©Ãû | Void clearAllViews() | ·µ»ØÖµ | Void | ²ÎÊý | ÎÞ | °¸Àý | var h = new Horizontal(); h.clearAllViews(); // Çå¿ÕËùÓпؼþ |
📌getViewCount »ñÈ¡ÊÓͼÊýÁ¿ Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ·µ»Øµ±Ç°ÈÝÆ÷ÖеÄÊÓͼÊýÁ¿ | ·½·¨Ç©Ãû | Int32 getViewCount() | ·µ»ØÖµ | Int32 | ²ÎÊý | ÎÞ | °¸Àý | var h = new Horizontal(); int count = h.getViewCount(); // »ñÈ¡×ӿؼþµÄÊýÁ¿ |
📌setSpacingÉèÖÿؼþ¼ä¾à Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÉèÖÃ×ӿؼþÖ®¼äµÄ¼ä¾à | ·½·¨Ç©Ãû | Void setSpacing(Int32 spacing) | ·µ»ØÖµ | Void | ²ÎÊý | - Int32 spacing £ºÒªÉèÖõÄ×ӿؼþ¼ä¾àÖµ | °¸Àý | var h = new Horizontal(); h.setSpacing(10); // ÉèÖÿؼþ¼ä¾àΪ10 |
📌setBackgroundColorÉèÖñ³¾°ÑÕÉ« Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ¸ù¾ÝÌṩµÄ RGB ÖµÉèÖÃÈÝÆ÷µÄ±³¾°ÑÕÉ« | ·½·¨Ç©Ãû | Void setBackgroundColor(Int32 red, Int32 green, Int32 blue) | ·µ»ØÖµ | Void | ²ÎÊý | - Int32 red £ººìÉ«·ÖÁ¿£¨Í¨³£È¡Öµ·¶Î§ 0~255 £©
- Int32 green £ºÂÌÉ«·ÖÁ¿£¨Í¨³£È¡Öµ·¶Î§ 0~255 £©
- Int32 blue £ºÀ¶É«·ÖÁ¿£¨Í¨³£È¡Öµ·¶Î§ 0~255 £© | °¸Àý | var h = new Horizontal(); h.setBackgroundColor(50,100, 150); // ÉèÖñ³¾°ÑÕɫΪºìÉ« |
📌setAlignment ÉèÖÃ¶ÔÆë·½Ê½ Àà±ð
| ÏêÇé˵Ã÷
| ·½·¨¹¦ÄÜ
| ÉèÖÃÈÝÆ÷ÄڿؼþµÄ¶ÔÆë·½Ê½
| ·½·¨Ç©Ãû
| Void setAlignment(String alignment)
| ·µ»ØÖµ
| Void
| ²ÎÊý
| -String alignment
£º¶ÔÆë·½Ê½£¬¿Éѡֵ£º -fill
£ºÌî³ä¶ÔÆë -left
£º×ó¶ÔÆë -right
£ºÓÒ¶ÔÆë -top
£º¶¥²¿¶ÔÆë -bottom
£ºµ×²¿¶ÔÆë -center
£º¾ÓÖÐ¶ÔÆë ĬÈÏֵΪfill
| °¸Àý
| var h = new Horizontal();
h.setAlignment("center"); // ÉèÖÃ¶ÔÆë·½Ê½Îª¾ÓÖÐ
/*
¿ÉѡֵÈçÏ£º
- fill: Ìî³ä¶ÔÆë
- left: ×ó¶ÔÆë
- right: ÓÒ¶ÔÆë
- top: ¶¥²¿¶ÔÆë
- bottom: µ×²¿¶ÔÆë
- center: ¾ÓÖÐ¶ÔÆë
ĬÈÏֵΪ fill¡£
*/
|
ʾÀý×Ó 1 ·ç¸ñ£º - // 🔨UI-ˮƽÈÝÆ÷[Horizontal]·½·¨ÍêÕûʾÀý
- // 🍎UI-ˮƽÈÝÆ÷[Horizontal]·½·¨Ð¡½á£¬½»Á÷QQȺ711841924
- printl("=== Horizontal¿Ø¼þ·½·¨ÍêÕûʾÀý ===");
- var vc = new IOSView();
- vc.show(() => {
- printl("HorizontalʾÀý½çÃæÒѼÓÔØ");
-
- // »ñÈ¡µ±Ç°ÊÓͼ
- var view = vc.getView();
-
- // ´´½¨Ö÷ÈÝÆ÷
- var mainContainer = new Vertical();
- mainContainer.setSpacing(15);
- mainContainer.setBackgroundColor(245, 245, 245);
-
- // ±êÌâÇøÓò
- var titleContainer = new Vertical();
- titleContainer.setAlignment("center");
- titleContainer.setSpacing(5);
- titleContainer.setBackgroundColor(0, 122, 255);
-
- var titleLabel = new Label();
- titleLabel.setText("🔨 Horizontal¿Ø¼þÑÝʾ");
- titleLabel.setFontSize(20.0);
- titleLabel.setTextColor(255, 255, 255);
- titleLabel.setTextAlignment("center");
-
- titleContainer.addView(titleLabel);
- mainContainer.addView(titleContainer);
-
- // Horizontal·½·¨ÑÝÊ¾ÇøÓò
- var demoContainer = new Vertical();
- demoContainer.setBackgroundColor(255, 255, 255);
- demoContainer.setSpacing(15);
-
- var demoTitle = new Label();
- demoTitle.setText("Horizontal¿Ø¼þ¹¦ÄÜÑÝʾ");
- demoTitle.setFontSize(16.0);
- demoTitle.setTextColor(0, 0, 0);
- demoTitle.setTextAlignment("center");
- demoContainer.addView(demoTitle);
-
- // µÚÒ»¸ö·½·¨£ºaddViewÌí¼Ó×ӿؼþ
- var addViewDemo = new Vertical();
- addViewDemo.setSpacing(5);
-
- var addViewLabel = new Label();
- addViewLabel.setText("📌 addViewÌí¼Ó×ӿؼþ");
- addViewLabel.setFontSize(14.0);
- addViewLabel.setTextColor(0, 122, 255);
- addViewDemo.addView(addViewLabel);
-
- var h1 = new Horizontal();
- h1.setSpacing(10);
- h1.setBackgroundColor(240, 240, 240);
-
- var btn1 = new Button();
- btn1.setText("°´Å¥1");
- btn1.setColor(0, 122, 255);
- btn1.setTextColor(255, 255, 255);
- btn1.setWidth(80);
- btn1.setHeight(40);
-
- var btn2 = new Button();
- btn2.setText("°´Å¥2");
- btn2.setColor(52, 199, 89);
- btn2.setTextColor(255, 255, 255);
- btn2.setWidth(80);
- btn2.setHeight(40);
-
- var btn3 = new Button();
- btn3.setText("°´Å¥3");
- btn3.setColor(255, 149, 0);
- btn3.setTextColor(255, 255, 255);
- btn3.setWidth(80);
- btn3.setHeight(40);
-
- // µÚÒ»¸ö·½·¨£ºaddViewÌí¼Ó×ӿؼþ
- h1.addView(btn1);
- h1.addView(btn2);
- h1.addView(btn3);
-
- addViewDemo.addView(h1);
- demoContainer.addView(addViewDemo);
-
- // µÚ¶þ¸ö·½·¨£ºremoveViewÒÆ³ýÊÓͼ
- var removeViewDemo = new Vertical();
- removeViewDemo.setSpacing(5);
-
- var removeViewLabel = new Label();
- removeViewLabel.setText("📌 removeViewÒÆ³ýÊÓͼ");
- removeViewLabel.setFontSize(14.0);
- removeViewLabel.setTextColor(0, 122, 255);
- removeViewDemo.addView(removeViewLabel);
-
- var h2 = new Horizontal();
- h2.setSpacing(10);
- h2.setBackgroundColor(240, 240, 240);
-
- var removeBtn1 = new Button();
- removeBtn1.setText("A");
- removeBtn1.setColor(0, 122, 255);
- removeBtn1.setTextColor(255, 255, 255);
- removeBtn1.setWidth(60);
- removeBtn1.setHeight(40);
-
- var removeBtn2 = new Button();
- removeBtn2.setText("B");
- removeBtn2.setColor(52, 199, 89);
- removeBtn2.setTextColor(255, 255, 255);
- removeBtn2.setWidth(60);
- removeBtn2.setHeight(40);
-
- var removeBtn3 = new Button();
- removeBtn3.setText("C");
- removeBtn3.setColor(255, 149, 0);
- removeBtn3.setTextColor(255, 255, 255);
- removeBtn3.setWidth(60);
- removeBtn3.setHeight(40);
-
- h2.addView(removeBtn1);
- h2.addView(removeBtn2);
- h2.addView(removeBtn3);
-
- var removeButton = new Button();
- removeButton.setText("ÒÆ³ýµÚÒ»¸ö");
- removeButton.setColor(255, 59, 48);
- removeButton.setTextColor(255, 255, 255);
- removeButton.setWidth(100);
- removeButton.setHeight(40);
-
- removeButton.onClick(() => {
- // µÚ¶þ¸ö·½·¨£ºremoveViewÒÆ³ýÊÓͼ
- if (h2.getViewCount() > 0) {
- h2.removeView(0); // ÒÆ³ýµÚÒ»¸ö×ӿؼþ
- printl("ÒÑÒÆ³ýµÚÒ»¸ö¿Ø¼þ£¬Ê£Óà¿Ø¼þÊý: " + h2.getViewCount());
- } else {
- printl("ûÓпÉÒÆ³ýµÄ¿Ø¼þ");
- }
- });
-
- var removeContainer = new Horizontal();
- removeContainer.setSpacing(10);
- removeContainer.addView(h2);
- removeContainer.addView(removeButton);
-
- removeViewDemo.addView(removeContainer);
- demoContainer.addView(removeViewDemo);
-
- // µÚÈý¸ö·½·¨£ºclearAllViewsÇå¿ÕËùÓÐÊÓͼ
- var clearAllViewsDemo = new Vertical();
- clearAllViewsDemo.setSpacing(5);
-
- var clearAllViewsLabel = new Label();
- clearAllViewsLabel.setText("📌 clearAllViewsÇå¿ÕËùÓÐÊÓͼ");
- clearAllViewsLabel.setFontSize(14.0);
- clearAllViewsLabel.setTextColor(0, 122, 255);
- clearAllViewsDemo.addView(clearAllViewsLabel);
-
- var h3 = new Horizontal();
- h3.setSpacing(10);
- h3.setBackgroundColor(240, 240, 240);
-
- var clearBtn1 = new Button();
- clearBtn1.setText("X");
- clearBtn1.setColor(0, 122, 255);
- clearBtn1.setTextColor(255, 255, 255);
- clearBtn1.setWidth(60);
- clearBtn1.setHeight(40);
-
- var clearBtn2 = new Button();
- clearBtn2.setText("Y");
- clearBtn2.setColor(52, 199, 89);
- clearBtn2.setTextColor(255, 255, 255);
- clearBtn2.setWidth(60);
- clearBtn2.setHeight(40);
-
- var clearBtn3 = new Button();
- clearBtn3.setText("Z");
- clearBtn3.setColor(255, 149, 0);
- clearBtn3.setTextColor(255, 255, 255);
- clearBtn3.setWidth(60);
- clearBtn3.setHeight(40);
-
- h3.addView(clearBtn1);
- h3.addView(clearBtn2);
- h3.addView(clearBtn3);
-
- var clearButton = new Button();
- clearButton.setText("Çå¿ÕËùÓÐ");
- clearButton.setColor(255, 59, 48);
- clearButton.setTextColor(255, 255, 255);
- clearButton.setWidth(100);
- clearButton.setHeight(40);
-
- clearButton.onClick(() => {
- // µÚÈý¸ö·½·¨£ºclearAllViewsÇå¿ÕËùÓÐÊÓͼ
- h3.clearAllViews(); // Çå¿ÕËùÓпؼþ
- printl("ÒÑÇå¿ÕËùÓпؼþ");
-
- // ÖØÐÂÌí¼ÓÒ»¸öÌáʾ±êÇ©
- var emptyLabel = new Label();
- emptyLabel.setText("ÒÑÇå¿Õ");
- emptyLabel.setFontSize(12.0);
- emptyLabel.setTextColor(100, 100, 100);
- h3.addView(emptyLabel);
- });
-
- var clearContainer = new Horizontal();
- clearContainer.setSpacing(10);
- clearContainer.addView(h3);
- clearContainer.addView(clearButton);
-
- clearAllViewsDemo.addView(clearContainer);
- demoContainer.addView(clearAllViewsDemo);
-
- // µÚËĸö·½·¨£ºgetViewCount »ñÈ¡ÊÓͼÊýÁ¿
- var getViewCountDemo = new Vertical();
- getViewCountDemo.setSpacing(5);
-
- var getViewCountLabel = new Label();
- getViewCountLabel.setText("📌 getViewCount »ñÈ¡ÊÓͼÊýÁ¿");
- getViewCountLabel.setFontSize(14.0);
- getViewCountLabel.setTextColor(0, 122, 255);
- getViewCountDemo.addView(getViewCountLabel);
-
- var h4 = new Horizontal();
- h4.setSpacing(10);
- h4.setBackgroundColor(240, 240, 240);
-
- var countBtn1 = new Button();
- countBtn1.setText("1");
- countBtn1.setColor(0, 122, 255);
- countBtn1.setTextColor(255, 255, 255);
- countBtn1.setWidth(60);
- countBtn1.setHeight(40);
-
- var countBtn2 = new Button();
- countBtn2.setText("2");
- countBtn2.setColor(52, 199, 89);
- countBtn2.setTextColor(255, 255, 255);
- countBtn2.setWidth(60);
- countBtn2.setHeight(40);
-
- h4.addView(countBtn1);
- h4.addView(countBtn2);
-
- var countButton = new Button();
- countButton.setText("»ñÈ¡ÊýÁ¿");
- countButton.setColor(111, 66, 193);
- countButton.setTextColor(255, 255, 255);
- countButton.setWidth(100);
- countButton.setHeight(40);
-
- countButton.onClick(() => {
- // µÚËĸö·½·¨£ºgetViewCount »ñÈ¡ÊÓͼÊýÁ¿
- var count = h4.getViewCount(); // »ñÈ¡×ӿؼþµÄÊýÁ¿
- printl("µ±Ç°¿Ø¼þÊýÁ¿: " + count);
-
- var resultLabel = new Label();
- resultLabel.setText("¿Ø¼þÊýÁ¿: " + count);
- resultLabel.setFontSize(12.0);
- resultLabel.setTextColor(111, 66, 193);
- getViewCountDemo.addView(resultLabel);
- });
-
- var countContainer = new Horizontal();
- countContainer.setSpacing(10);
- countContainer.addView(h4);
- countContainer.addView(countButton);
-
- getViewCountDemo.addView(countContainer);
- demoContainer.addView(getViewCountDemo);
-
- // µÚÎå¸ö·½·¨£ºsetSpacingÉèÖÿؼþ¼ä¾à
- var setSpacingDemo = new Vertical();
- setSpacingDemo.setSpacing(5);
-
- var setSpacingLabel = new Label();
- setSpacingLabel.setText("📌 setSpacingÉèÖÿؼþ¼ä¾à");
- setSpacingLabel.setFontSize(14.0);
- setSpacingLabel.setTextColor(0, 122, 255);
- setSpacingDemo.addView(setSpacingLabel);
-
- var h5 = new Horizontal();
- // µÚÎå¸ö·½·¨£ºsetSpacingÉèÖÿؼþ¼ä¾à
- h5.setSpacing(20); // ÉèÖÿؼþ¼ä¾àΪ20
- h5.setBackgroundColor(240, 240, 240);
-
- var spacingBtn1 = new Button();
- spacingBtn1.setText("¼ä¾à´ó");
- spacingBtn1.setColor(0, 122, 255);
- spacingBtn1.setTextColor(255, 255, 255);
- spacingBtn1.setWidth(80);
- spacingBtn1.setHeight(40);
-
- var spacingBtn2 = new Button();
- spacingBtn2.setText("¼ä¾à´ó");
- spacingBtn2.setColor(52, 199, 89);
- spacingBtn2.setTextColor(255, 255, 255);
- spacingBtn2.setWidth(80);
- spacingBtn2.setHeight(40);
-
- h5.addView(spacingBtn1);
- h5.addView(spacingBtn2);
-
- setSpacingDemo.addView(h5);
- demoContainer.addView(setSpacingDemo);
-
- // µÚÁù¸ö·½·¨£ºsetBackgroundColorÉèÖñ³¾°ÑÕÉ«
- var setBackgroundColorDemo = new Vertical();
- setBackgroundColorDemo.setSpacing(5);
-
- var setBackgroundColorLabel = new Label();
- setBackgroundColorLabel.setText("📌 setBackgroundColorÉèÖñ³¾°ÑÕÉ«");
- setBackgroundColorLabel.setFontSize(14.0);
- setBackgroundColorLabel.setTextColor(0, 122, 255);
- setBackgroundColorDemo.addView(setBackgroundColorLabel);
-
- var h6 = new Horizontal();
- h6.setSpacing(10);
- // µÚÁù¸ö·½·¨£ºsetBackgroundColorÉèÖñ³¾°ÑÕÉ«
- h6.setBackgroundColor(50, 100, 150); // ÉèÖñ³¾°ÑÕɫΪRGB(50,100,150)
-
- var bgBtn1 = new Button();
- bgBtn1.setText("±³¾°É«1");
- bgBtn1.setColor(255, 255, 255);
- bgBtn1.setTextColor(0, 0, 0);
- bgBtn1.setWidth(80);
- bgBtn1.setHeight(40);
-
- var bgBtn2 = new Button();
- bgBtn2.setText("±³¾°É«2");
- bgBtn2.setColor(255, 255, 255);
- bgBtn2.setTextColor(0, 0, 0);
- bgBtn2.setWidth(80);
- bgBtn2.setHeight(40);
-
- h6.addView(bgBtn1);
- h6.addView(bgBtn2);
-
- setBackgroundColorDemo.addView(h6);
- demoContainer.addView(setBackgroundColorDemo);
-
- // µÚÆß¸ö·½·¨£ºsetAlignment ÉèÖÃ¶ÔÆë·½Ê½
- var setAlignmentDemo = new Vertical();
- setAlignmentDemo.setSpacing(5);
-
- var setAlignmentLabel = new Label();
- setAlignmentLabel.setText("📌 setAlignment ÉèÖÃ¶ÔÆë·½Ê½");
- setAlignmentLabel.setFontSize(14.0);
- setAlignmentLabel.setTextColor(0, 122, 255);
- setAlignmentDemo.addView(setAlignmentLabel);
-
- // ¾ÓÖÐ¶ÔÆëʾÀý
- var hCenter = new Horizontal();
- hCenter.setSpacing(10);
- hCenter.setBackgroundColor(240, 240, 240);
- // µÚÆß¸ö·½·¨£ºsetAlignment ÉèÖÃ¶ÔÆë·½Ê½
- hCenter.setAlignment("center"); // ÉèÖÃ¶ÔÆë·½Ê½Îª¾ÓÖÐ
-
- var centerBtn = new Button();
- centerBtn.setText("¾ÓÖÐ");
- centerBtn.setColor(0, 122, 255);
- centerBtn.setTextColor(255, 255, 255);
- centerBtn.setWidth(80);
- centerBtn.setHeight(40);
-
- hCenter.addView(centerBtn);
-
- var centerLabel = new Label();
- centerLabel.setText("¾ÓÖÐ¶ÔÆë");
- centerLabel.setFontSize(12.0);
- centerLabel.setTextColor(100, 100, 100);
-
- setAlignmentDemo.addView(centerLabel);
- setAlignmentDemo.addView(hCenter);
-
- // ×ó¶ÔÆëʾÀý
- var hLeft = new Horizontal();
- hLeft.setSpacing(10);
- hLeft.setBackgroundColor(240, 240, 240);
- hLeft.setAlignment("left"); // ÉèÖÃ¶ÔÆë·½Ê½Îª×ó¶ÔÆë
-
- var leftBtn = new Button();
- leftBtn.setText("×ó¶ÔÆë");
- leftBtn.setColor(52, 199, 89);
- leftBtn.setTextColor(255, 255, 255);
- leftBtn.setWidth(80);
- leftBtn.setHeight(40);
-
- hLeft.addView(leftBtn);
-
- var leftLabel = new Label();
- leftLabel.setText("×ó¶ÔÆë");
- leftLabel.setFontSize(12.0);
- leftLabel.setTextColor(100, 100, 100);
-
- setAlignmentDemo.addView(leftLabel);
- setAlignmentDemo.addView(hLeft);
-
- // ÓÒ¶ÔÆëʾÀý
- var hRight = new Horizontal();
- hRight.setSpacing(10);
- hRight.setBackgroundColor(240, 240, 240);
- hRight.setAlignment("right"); // ÉèÖÃ¶ÔÆë·½Ê½ÎªÓÒ¶ÔÆë
-
- var rightBtn = new Button();
- rightBtn.setText("ÓÒ¶ÔÆë");
- rightBtn.setColor(255, 149, 0);
- rightBtn.setTextColor(255, 255, 255);
- rightBtn.setWidth(80);
- rightBtn.setHeight(40);
-
- hRight.addView(rightBtn);
-
- var rightLabel = new Label();
- rightLabel.setText("ÓÒ¶ÔÆë");
- rightLabel.setFontSize(12.0);
- rightLabel.setTextColor(100, 100, 100);
-
- setAlignmentDemo.addView(rightLabel);
- setAlignmentDemo.addView(hRight);
-
- demoContainer.addView(setAlignmentDemo);
-
- mainContainer.addView(demoContainer);
-
- // ʵ¼ÊÓ¦ÓÃʾÀý
- var applicationContainer = new Vertical();
- applicationContainer.setBackgroundColor(255, 255, 255);
- applicationContainer.setSpacing(15);
-
- var appTitle = new Label();
- appTitle.setText("Horizontalʵ¼ÊÓ¦ÓÃʾÀý");
- appTitle.setFontSize(16.0);
- appTitle.setTextColor(0, 0, 0);
- appTitle.setTextAlignment("center");
- applicationContainer.addView(appTitle);
-
- // °´Å¥×éʾÀý
- var buttonGroup = new Horizontal();
- buttonGroup.setSpacing(10);
- buttonGroup.setAlignment("center");
- buttonGroup.setBackgroundColor(240, 240, 240);
-
- var homeBtn = new Button();
- homeBtn.setText("🏠 Ê×Ò³");
- homeBtn.setColor(0, 122, 255);
- homeBtn.setTextColor(255, 255, 255);
- homeBtn.setWidth(80);
- homeBtn.setHeight(40);
-
- var searchBtn = new Button();
- searchBtn.setText("🔍 ËÑË÷");
- searchBtn.setColor(52, 199, 89);
- searchBtn.setTextColor(255, 255, 255);
- searchBtn.setWidth(80);
- searchBtn.setHeight(40);
-
- var profileBtn = new Button();
- profileBtn.setText("👤 ÎÒµÄ");
- profileBtn.setColor(255, 149, 0);
- profileBtn.setTextColor(255, 255, 255);
- profileBtn.setWidth(80);
- profileBtn.setHeight(40);
-
- buttonGroup.addView(homeBtn);
- buttonGroup.addView(searchBtn);
- buttonGroup.addView(profileBtn);
-
- applicationContainer.addView(buttonGroup);
-
- // ͼ±ê+ÎÄ×Ö×éºÏʾÀý
- var iconTextGroup = new Horizontal();
- iconTextGroup.setSpacing(20);
- iconTextGroup.setAlignment("center");
- iconTextGroup.setBackgroundColor(245, 245, 245);
-
- // µÚÒ»×é
- var group1 = new Vertical();
- group1.setSpacing(5);
- group1.setAlignment("center");
-
- var icon1 = new Label();
- icon1.setText("📧");
- icon1.setFontSize(24.0);
- icon1.setTextAlignment("center");
-
- var text1 = new Label();
- text1.setText("Óʼþ");
- text1.setFontSize(12.0);
- text1.setTextAlignment("center");
- text1.setTextColor(100, 100, 100);
-
- group1.addView(icon1);
- group1.addView(text1);
-
- // µÚ¶þ×é
- var group2 = new Vertical();
- group2.setSpacing(5);
- group2.setAlignment("center");
-
- var icon2 = new Label();
- icon2.setText("📅");
- icon2.setFontSize(24.0);
- icon2.setTextAlignment("center");
-
- var text2 = new Label();
- text2.setText("ÈÕÀú");
- text2.setFontSize(12.0);
- text2.setTextAlignment("center");
- text2.setTextColor(100, 100, 100);
-
- group2.addView(icon2);
- group2.addView(text2);
-
- // µÚÈý×é
- var group3 = new Vertical();
- group3.setSpacing(5);
- group3.setAlignment("center");
-
- var icon3 = new Label();
- icon3.setText("📷");
- icon3.setFontSize(24.0);
- icon3.setTextAlignment("center");
-
- var text3 = new Label();
- text3.setText("Ïà»ú");
- text3.setFontSize(12.0);
- text3.setTextAlignment("center");
- text3.setTextColor(100, 100, 100);
-
- group3.addView(icon3);
- group3.addView(text3);
-
- iconTextGroup.addView(group1);
- iconTextGroup.addView(group2);
- iconTextGroup.addView(group3);
-
- applicationContainer.addView(iconTextGroup);
- mainContainer.addView(applicationContainer);
-
- // ¿Ø¼þÐÅÏ¢ÇøÓò
- var infoContainer = new Vertical();
- infoContainer.setBackgroundColor(236, 245, 255);
- infoContainer.setSpacing(8);
-
- var infoTitle = new Label();
- infoTitle.setText("ℹ️ Horizontal¿Ø¼þ˵Ã÷");
- infoTitle.setFontSize(16.0);
- infoTitle.setTextColor(0, 122, 255);
- infoContainer.addView(infoTitle);
-
- var info1 = new Label();
- info1.setText("• Horizontal¿Ø¼þÓÃÓÚˮƽÅÅÁÐ×ӿؼþ");
- info1.setFontSize(12.0);
- info1.setTextColor(52, 58, 64);
- infoContainer.addView(info1);
-
- var info2 = new Label();
- info2.setText("• Ö§³ÖÌí¼Ó¡¢ÒƳý¡¢Çå¿Õ×ӿؼþ");
- info2.setFontSize(12.0);
- info2.setTextColor(52, 58, 64);
- infoContainer.addView(info2);
-
- var info3 = new Label();
- info3.setText("• ¿ÉÉèÖüä¾à¡¢±³¾°É«ºÍ¶ÔÆë·½Ê½");
- info3.setFontSize(12.0);
- info3.setTextColor(52, 58, 64);
- infoContainer.addView(info3);
-
- mainContainer.addView(infoContainer);
-
- // µ×²¿°´Å¥
- var bottomContainer = new Horizontal();
- bottomContainer.setSpacing(10);
- bottomContainer.setAlignment("center");
-
- var exitBtn = new Button();
- exitBtn.setText("Í˳öʾÀý");
- exitBtn.setColor(255, 59, 48);
- exitBtn.setTextColor(255, 255, 255);
- exitBtn.setHeight(40);
-
- exitBtn.onClick(() => {
- printl("Í˳ö°´Å¥±»µã»÷");
- vc.dismiss();
- });
-
- bottomContainer.addView(exitBtn);
- mainContainer.addView(bottomContainer);
-
- // Ìí¼Óµ½Ö÷ÊÓͼ
- view.addView(mainContainer);
-
- printl("HorizontalʾÀý½çÃæ¹¹½¨Íê³É");
- });
- printl("Horizontal¿Ø¼þÍêÕûʾÀýÒÑÆô¶¯");
¸´ÖÆ´úÂë
|