1 using Tizen.NUI.BaseComponents;
2 using Tizen.NUI.Components;
4 namespace Tizen.NUI.Samples
6 public class TextFieldLayoutTest : IExample
9 private ScrollableBase rootView;
11 public void Activate()
13 window = NUIApplication.GetDefaultWindow();
15 rootView = new ScrollableBase()
17 ScrollingDirection = ScrollableBase.Direction.Vertical,
18 HideScrollbar = false,
19 WidthSpecification = LayoutParamPolicies.MatchParent,
20 HeightSpecification = LayoutParamPolicies.MatchParent,
21 BackgroundColor = Color.White,
25 var mainView = new View()
27 Layout = new LinearLayout()
29 LinearOrientation = LinearLayout.Orientation.Vertical,
30 CellPadding = new Size2D(0, 20),
32 WidthSpecification = LayoutParamPolicies.MatchParent,
33 BackgroundColor = Color.White,
35 rootView.Add(mainView);
37 var absoluteViewTitle = new TextLabel()
39 Text = "AbsoluteLayout",
40 WidthSpecification = LayoutParamPolicies.MatchParent,
42 mainView.Add(absoluteViewTitle);
44 var absoluteView = new View()
46 Layout = new AbsoluteLayout(),
47 WidthSpecification = LayoutParamPolicies.MatchParent,
48 HeightSpecification = 150,
49 BackgroundColor = Color.White,
51 mainView.Add(absoluteView);
53 var absoluteTopText = new TextField()
55 WidthSpecification = LayoutParamPolicies.MatchParent,
56 BackgroundColor = Color.Red,
58 absoluteTopText.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
60 global::System.Console.WriteLine($"AbsoluteLayout Top Text has been changed to \"{args.TextField.Text}\".");
62 absoluteView.Add(absoluteTopText);
64 var absoluteCenterText = new TextField()
67 BackgroundColor = Color.Blue,
68 ParentOrigin = new Position(0.5f, 0.5f, 0.5f),
69 PivotPoint = new Position(0.5f, 0.5f, 0.5f),
70 PositionUsesPivotPoint = true,
72 absoluteCenterText.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
74 global::System.Console.WriteLine($"AbsoluteLayout Center Text has been changed to \"{args.TextField.Text}\".");
76 absoluteView.Add(absoluteCenterText);
78 var absoluteBottomText = new TextField()
81 BackgroundColor = Color.Green,
82 ParentOrigin = new Position(0.5f, 1.0f, 0.5f),
83 PivotPoint = new Position(0.5f, 1.0f, 0.5f),
84 PositionUsesPivotPoint = true,
86 absoluteBottomText.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
88 global::System.Console.WriteLine($"AbsoluteLayout Bottom Text has been changed to \"{args.TextField.Text}\".");
90 absoluteView.Add(absoluteBottomText);
92 var linearViewTitle = new TextLabel()
94 Text = "LinearLayout",
95 WidthSpecification = LayoutParamPolicies.MatchParent,
97 mainView.Add(linearViewTitle);
99 var linearView = new View()
101 Layout = new LinearLayout()
103 CellPadding = new Size2D(10, 0),
105 WidthSpecification = LayoutParamPolicies.MatchParent,
106 BackgroundColor = Color.White,
108 mainView.Add(linearView);
110 var linearLeft = new View()
112 Layout = new LinearLayout()
114 LinearOrientation = LinearLayout.Orientation.Vertical,
115 CellPadding = new Size2D(0, 10),
117 WidthSpecification = LayoutParamPolicies.MatchParent,
118 BackgroundColor = Color.White,
120 linearView.Add(linearLeft);
122 var linearLeftText1 = new TextField()
124 WidthSpecification = LayoutParamPolicies.MatchParent,
125 BackgroundColor = Color.Red,
127 linearLeftText1.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
129 global::System.Console.WriteLine($"LinearLayout Left default size Text has been changed to \"{args.TextField.Text}\".");
131 linearLeft.Add(linearLeftText1);
133 var linearLeftText2 = new TextField()
136 WidthSpecification = LayoutParamPolicies.MatchParent,
137 BackgroundColor = Color.Red,
139 linearLeftText2.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
141 global::System.Console.WriteLine($"LinearLayout Left PixelSize 16 Text has been changed to \"{args.TextField.Text}\".");
143 linearLeft.Add(linearLeftText2);
145 var linearLeftText3 = new TextField()
148 WidthSpecification = LayoutParamPolicies.MatchParent,
149 BackgroundColor = Color.Red,
151 linearLeftText3.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
153 global::System.Console.WriteLine($"LinearLayout Left PixelSize 64 Text has been changed to \"{args.TextField.Text}\".");
155 linearLeft.Add(linearLeftText3);
157 var linearLeftText4 = new TextField()
159 BackgroundColor = Color.Red,
161 linearLeftText4.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
163 global::System.Console.WriteLine($"LinearLayout Left Text with WrapContent WidthSpecification has been changed to \"{args.TextField.Text}\".");
165 linearLeft.Add(linearLeftText4);
167 var linearRight = new View()
169 Layout = new LinearLayout()
171 LinearOrientation = LinearLayout.Orientation.Vertical,
172 CellPadding = new Size2D(0, 10),
174 WidthSpecification = LayoutParamPolicies.MatchParent,
175 BackgroundColor = Color.White,
177 linearView.Add(linearRight);
179 var linearRightText1 = new TextField()
182 WidthSpecification = LayoutParamPolicies.MatchParent,
183 BackgroundColor = Color.Red,
185 linearRightText1.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
187 global::System.Console.WriteLine($"LinearLayout Right default size Text has been changed to \"{args.TextField.Text}\".");
189 linearRight.Add(linearRightText1);
191 var linearRightText2 = new TextField()
195 WidthSpecification = LayoutParamPolicies.MatchParent,
196 BackgroundColor = Color.Red,
198 linearRightText2.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
200 global::System.Console.WriteLine($"LinearLayout Right PixelSize 16 Text has been changed to \"{args.TextField.Text}\".");
202 linearRight.Add(linearRightText2);
204 var linearRightText3 = new TextField()
208 WidthSpecification = LayoutParamPolicies.MatchParent,
209 BackgroundColor = Color.Red,
211 linearRightText3.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
213 global::System.Console.WriteLine($"LinearLayout Right PixelSize 64 Text has been changed to \"{args.TextField.Text}\".");
215 linearRight.Add(linearRightText3);
217 var linearRightText4 = new TextField()
219 Text = "WrapContent",
220 BackgroundColor = Color.Red,
222 linearRightText4.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
224 global::System.Console.WriteLine($"LinearLayout Right Text with WrapContent WidthSpecification has been changed to \"{args.TextField.Text}\".");
226 linearRight.Add(linearRightText4);
228 var gridViewTitle = new TextLabel()
231 WidthSpecification = LayoutParamPolicies.MatchParent,
233 mainView.Add(gridViewTitle);
235 var gridView = new View()
237 Layout = new GridLayout()
244 WidthSpecification = LayoutParamPolicies.MatchParent,
245 BackgroundColor = Color.White,
247 mainView.Add(gridView);
249 var gridCol1Text1 = new TextField()
251 BackgroundColor = Color.Green,
253 gridCol1Text1.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
255 global::System.Console.WriteLine($"GridLayout Column 1 default size Text has been changed to \"{args.TextField.Text}\".");
257 GridLayout.SetRow(gridCol1Text1, 0);
258 GridLayout.SetColumn(gridCol1Text1, 0);
259 GridLayout.SetHorizontalStretch(gridCol1Text1, GridLayout.StretchFlags.ExpandAndFill);
260 GridLayout.SetVerticalStretch(gridCol1Text1, GridLayout.StretchFlags.ExpandAndFill);
261 gridView.Add(gridCol1Text1);
263 var gridCol1Text2 = new TextField()
266 BackgroundColor = Color.Green,
268 gridCol1Text2.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
270 global::System.Console.WriteLine($"GridLayout Column 1 PixelSize 16 Text has been changed to \"{args.TextField.Text}\".");
272 GridLayout.SetRow(gridCol1Text2, 1);
273 GridLayout.SetColumn(gridCol1Text2, 0);
274 GridLayout.SetHorizontalStretch(gridCol1Text2, GridLayout.StretchFlags.ExpandAndFill);
275 GridLayout.SetVerticalStretch(gridCol1Text2, GridLayout.StretchFlags.ExpandAndFill);
276 gridView.Add(gridCol1Text2);
278 var gridCol1Text3 = new TextField()
281 BackgroundColor = Color.Green,
283 gridCol1Text3.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
285 global::System.Console.WriteLine($"GridLayout Column 1 PixelSize 64 Text has been changed to \"{args.TextField.Text}\".");
287 GridLayout.SetRow(gridCol1Text3, 2);
288 GridLayout.SetColumn(gridCol1Text3, 0);
289 GridLayout.SetHorizontalStretch(gridCol1Text3, GridLayout.StretchFlags.ExpandAndFill);
290 GridLayout.SetVerticalStretch(gridCol1Text3, GridLayout.StretchFlags.ExpandAndFill);
291 gridView.Add(gridCol1Text3);
293 var gridCol1Text4 = new TextField()
295 BackgroundColor = Color.Green,
297 gridCol1Text4.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
299 global::System.Console.WriteLine($"GridLayout Column 1 Text with Fill has been changed to \"{args.TextField.Text}\".");
301 GridLayout.SetRow(gridCol1Text4, 3);
302 GridLayout.SetColumn(gridCol1Text4, 0);
303 GridLayout.SetHorizontalStretch(gridCol1Text4, GridLayout.StretchFlags.Fill);
304 GridLayout.SetVerticalStretch(gridCol1Text4, GridLayout.StretchFlags.Fill);
305 gridView.Add(gridCol1Text4);
307 var gridCol1Text5 = new TextField()
309 BackgroundColor = Color.Green,
311 gridCol1Text5.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
313 global::System.Console.WriteLine($"GridLayout Column 1 Text with Expand has been changed to \"{args.TextField.Text}\".");
315 GridLayout.SetRow(gridCol1Text5, 4);
316 GridLayout.SetColumn(gridCol1Text5, 0);
317 GridLayout.SetHorizontalStretch(gridCol1Text5, GridLayout.StretchFlags.Expand);
318 GridLayout.SetVerticalStretch(gridCol1Text5, GridLayout.StretchFlags.Expand);
319 gridView.Add(gridCol1Text5);
321 var gridCol2Text1 = new TextField()
324 BackgroundColor = Color.Green,
326 gridCol2Text1.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
328 global::System.Console.WriteLine($"GridLayout Column 2 default size Text has been changed to \"{args.TextField.Text}\".");
330 GridLayout.SetRow(gridCol2Text1, 0);
331 GridLayout.SetColumn(gridCol2Text1, 1);
332 GridLayout.SetHorizontalStretch(gridCol2Text1, GridLayout.StretchFlags.ExpandAndFill);
333 GridLayout.SetVerticalStretch(gridCol2Text1, GridLayout.StretchFlags.ExpandAndFill);
334 gridView.Add(gridCol2Text1);
336 var gridCol2Text2 = new TextField()
340 BackgroundColor = Color.Green,
342 gridCol2Text2.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
344 global::System.Console.WriteLine($"GridLayout Column 2 PixelSize 16 Text has been changed to \"{args.TextField.Text}\".");
346 GridLayout.SetRow(gridCol2Text2, 1);
347 GridLayout.SetColumn(gridCol2Text2, 1);
348 GridLayout.SetHorizontalStretch(gridCol2Text2, GridLayout.StretchFlags.ExpandAndFill);
349 GridLayout.SetVerticalStretch(gridCol2Text2, GridLayout.StretchFlags.ExpandAndFill);
350 gridView.Add(gridCol2Text2);
352 var gridCol2Text3 = new TextField()
356 BackgroundColor = Color.Green,
358 gridCol2Text3.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
360 global::System.Console.WriteLine($"GridLayout Column 2 PixelSize 64 Text has been changed to \"{args.TextField.Text}\".");
362 GridLayout.SetRow(gridCol2Text3, 2);
363 GridLayout.SetColumn(gridCol2Text3, 1);
364 GridLayout.SetHorizontalStretch(gridCol2Text3, GridLayout.StretchFlags.ExpandAndFill);
365 GridLayout.SetVerticalStretch(gridCol2Text3, GridLayout.StretchFlags.ExpandAndFill);
366 gridView.Add(gridCol2Text3);
368 var gridCol2Text4 = new TextField()
371 BackgroundColor = Color.Green,
373 gridCol2Text4.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
375 global::System.Console.WriteLine($"GridLayout Column 2 Text with Fill has been changed to \"{args.TextField.Text}\".");
377 GridLayout.SetRow(gridCol2Text4, 3);
378 GridLayout.SetColumn(gridCol2Text4, 1);
379 GridLayout.SetHorizontalStretch(gridCol2Text4, GridLayout.StretchFlags.Fill);
380 GridLayout.SetVerticalStretch(gridCol2Text4, GridLayout.StretchFlags.ExpandAndFill);
381 gridView.Add(gridCol2Text4);
383 var gridCol2Text5 = new TextField()
386 BackgroundColor = Color.Green,
388 gridCol2Text5.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
390 global::System.Console.WriteLine($"GridLayout Column 2 Text with Expand has been changed to \"{args.TextField.Text}\".");
392 GridLayout.SetRow(gridCol2Text5, 4);
393 GridLayout.SetColumn(gridCol2Text5, 1);
394 GridLayout.SetHorizontalStretch(gridCol2Text5, GridLayout.StretchFlags.Expand);
395 GridLayout.SetVerticalStretch(gridCol2Text5, GridLayout.StretchFlags.ExpandAndFill);
396 gridView.Add(gridCol2Text5);
398 var relativeViewTitle = new TextLabel()
400 Text = "RelativeLayout",
401 WidthSpecification = LayoutParamPolicies.MatchParent,
403 mainView.Add(relativeViewTitle);
405 var relativeView = new View()
407 Layout = new RelativeLayout(),
408 WidthSpecification = LayoutParamPolicies.MatchParent,
409 BackgroundColor = Color.White,
411 mainView.Add(relativeView);
413 var relTopText = new TextField()
415 Text = "Top with Fill",
416 HorizontalAlignment = HorizontalAlignment.Center,
417 BackgroundColor = Color.Red,
419 relTopText.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
421 global::System.Console.WriteLine($"RelativeLayout Top Text has been changed to \"{args.TextField.Text}\".");
423 RelativeLayout.SetTopRelativeOffset(relTopText, 0.0f);
424 RelativeLayout.SetBottomRelativeOffset(relTopText, 0.0f);
425 RelativeLayout.SetLeftRelativeOffset(relTopText, 0.0f);
426 RelativeLayout.SetRightRelativeOffset(relTopText, 1.0f);
427 RelativeLayout.SetFillHorizontal(relTopText, true);
428 relativeView.Add(relTopText);
430 var relLeftText = new TextField()
433 BackgroundColor = Color.Green,
435 relLeftText.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
437 global::System.Console.WriteLine($"RelativeLayout Left Text has been changed to \"{args.TextField.Text}\".");
439 RelativeLayout.SetTopTarget(relLeftText, relTopText);
440 RelativeLayout.SetTopRelativeOffset(relLeftText, 1.0f);
441 RelativeLayout.SetBottomTarget(relLeftText, relTopText);
442 RelativeLayout.SetBottomRelativeOffset(relLeftText, 1.0f);
443 RelativeLayout.SetLeftRelativeOffset(relLeftText, 0.0f);
444 RelativeLayout.SetRightRelativeOffset(relLeftText, 0.0f);
445 relativeView.Add(relLeftText);
447 var relRightText = new TextField()
450 BackgroundColor = Color.Blue,
452 relRightText.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
454 global::System.Console.WriteLine($"RelativeLayout Right Text has been changed to \"{args.TextField.Text}\".");
456 RelativeLayout.SetTopTarget(relRightText, relTopText);
457 RelativeLayout.SetTopRelativeOffset(relRightText, 1.0f);
458 RelativeLayout.SetBottomTarget(relRightText, relTopText);
459 RelativeLayout.SetBottomRelativeOffset(relRightText, 1.0f);
460 RelativeLayout.SetLeftRelativeOffset(relRightText, 1.0f);
461 RelativeLayout.SetRightRelativeOffset(relRightText, 1.0f);
462 RelativeLayout.SetHorizontalAlignment(relRightText, RelativeLayout.Alignment.End);
463 relativeView.Add(relRightText);
465 var relBottomText = new TextField()
468 BackgroundColor = Color.Yellow,
470 relBottomText.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
472 global::System.Console.WriteLine($"RelativeLayout Bottom Text has been changed to \"{args.TextField.Text}\".");
474 RelativeLayout.SetTopRelativeOffset(relBottomText, 1.0f);
475 RelativeLayout.SetBottomRelativeOffset(relBottomText, 1.0f);
476 RelativeLayout.SetLeftTarget(relBottomText, relLeftText);
477 RelativeLayout.SetLeftRelativeOffset(relBottomText, 1.0f);
478 RelativeLayout.SetRightTarget(relBottomText, relRightText);
479 RelativeLayout.SetRightRelativeOffset(relBottomText, 0.0f);
480 RelativeLayout.SetHorizontalAlignment(relBottomText, RelativeLayout.Alignment.Center);
481 RelativeLayout.SetVerticalAlignment(relBottomText, RelativeLayout.Alignment.End);
482 relativeView.Add(relBottomText);
484 var relCenterText = new TextField()
486 BackgroundColor = Color.Purple,
488 relCenterText.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
490 global::System.Console.WriteLine($"RelativeLayout Center Text has been changed to \"{args.TextField.Text}\".");
492 RelativeLayout.SetTopTarget(relCenterText, relTopText);
493 RelativeLayout.SetTopRelativeOffset(relCenterText, 1.0f);
494 RelativeLayout.SetBottomTarget(relCenterText, relBottomText);
495 RelativeLayout.SetBottomRelativeOffset(relCenterText, 0.0f);
496 RelativeLayout.SetLeftTarget(relCenterText, relLeftText);
497 RelativeLayout.SetLeftRelativeOffset(relCenterText, 1.0f);
498 RelativeLayout.SetRightTarget(relCenterText, relRightText);
499 RelativeLayout.SetRightRelativeOffset(relCenterText, 0.0f);
500 RelativeLayout.SetFillHorizontal(relCenterText, true);
501 relativeView.Add(relCenterText);
503 var flexRowViewTitle = new TextLabel()
505 Text = "FlexLayout with Row Direction",
506 WidthSpecification = LayoutParamPolicies.MatchParent,
508 mainView.Add(flexRowViewTitle);
510 var flexRowView = new View()
512 Layout = new FlexLayout()
514 Direction = FlexLayout.FlexDirection.Row,
515 WrapType = FlexLayout.FlexWrapType.Wrap,
516 Alignment = FlexLayout.AlignmentType.Center,
517 ItemsAlignment = FlexLayout.AlignmentType.Center,
518 Justification = FlexLayout.FlexJustification.SpaceEvenly,
520 WidthSpecification = LayoutParamPolicies.MatchParent,
521 BackgroundColor = Color.White,
523 mainView.Add(flexRowView);
525 var flexRowText1 = new TextField()
528 BackgroundColor = Color.Red,
530 flexRowText1.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
532 global::System.Console.WriteLine($"FlexLayout with Row First Text has been changed to \"{args.TextField.Text}\".");
534 flexRowView.Add(flexRowText1);
536 var flexRowText2 = new TextField()
539 BackgroundColor = Color.Green,
541 flexRowText2.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
543 global::System.Console.WriteLine($"FlexLayout with Row Second Text has been changed to \"{args.TextField.Text}\".");
545 flexRowView.Add(flexRowText2);
547 var flexRowText3 = new TextField()
550 BackgroundColor = Color.Blue,
552 flexRowText3.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
554 global::System.Console.WriteLine($"FlexLayout with Row Third Text has been changed to \"{args.TextField.Text}\".");
556 flexRowView.Add(flexRowText3);
558 var flexRowText4 = new TextField()
561 BackgroundColor = Color.Yellow,
563 flexRowText4.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
565 global::System.Console.WriteLine($"FlexLayout with Row Fourth Text has been changed to \"{args.TextField.Text}\".");
567 flexRowView.Add(flexRowText4);
569 var flexColViewTitle = new TextField()
571 Text = "FlexLayout with Column Direction",
572 WidthSpecification = LayoutParamPolicies.MatchParent,
574 mainView.Add(flexColViewTitle);
576 var flexColView = new View()
578 Layout = new FlexLayout()
580 Direction = FlexLayout.FlexDirection.Column,
581 WrapType = FlexLayout.FlexWrapType.Wrap,
582 Alignment = FlexLayout.AlignmentType.Center,
583 ItemsAlignment = FlexLayout.AlignmentType.Center,
584 Justification = FlexLayout.FlexJustification.SpaceEvenly,
586 WidthSpecification = LayoutParamPolicies.MatchParent,
587 HeightSpecification = 150,
588 BackgroundColor = Color.White,
590 mainView.Add(flexColView);
592 var flexColText1 = new TextField()
595 BackgroundColor = Color.Red,
597 flexColText1.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
599 global::System.Console.WriteLine($"FlexLayout with Column First Text has been changed to \"{args.TextField.Text}\".");
601 flexColView.Add(flexColText1);
603 var flexColText2 = new TextField()
606 BackgroundColor = Color.Green,
608 flexColText2.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
610 global::System.Console.WriteLine($"FlexLayout with Column Second Text has been changed to \"{args.TextField.Text}\".");
612 flexColView.Add(flexColText2);
614 var flexColText3 = new TextField()
617 BackgroundColor = Color.Blue,
619 flexColText3.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
621 global::System.Console.WriteLine($"FlexLayout with Column Third Text has been changed to \"{args.TextField.Text}\".");
623 flexColView.Add(flexColText3);
625 var flexColText4 = new TextField()
628 BackgroundColor = Color.Yellow,
630 flexColText4.TextChanged += (object sender, TextField.TextChangedEventArgs args) =>
632 global::System.Console.WriteLine($"FlexLayout with Column Fourth Text has been changed to \"{args.TextField.Text}\".");
634 flexColView.Add(flexColText4);
637 public void Deactivate()
639 window.Remove(rootView);