NativeScript for Mobile App Development UI Components and Layouts 2 — Questions and Answers
Question 1: What property controls the orientation of a StackLayout?
- orientation (Correct answer)
- direction
- axis
- flow
Correct answer: orientation
The `orientation` property accepts 'vertical' (default) or 'horizontal' to control how children are stacked.
Question 2: In GridLayout, how do you define three equal columns?
- columns='*, *, *' (Correct answer)
- columns='1, 1, 1'
- columns='auto, auto, auto'
- columns='33%, 33%, 33%'
Correct answer: columns='*, *, *'
Using star (*) values in the columns property divides available space equally among columns.
Question 3: Which component displays an image from a URL in NativeScript?
- Image (Correct answer)
- ImageView
- Picture
- AsyncImage
Correct answer: Image
The Image component renders images from local resources or remote URLs on both platforms.
Question 4: What does the `tap` event correspond to in NativeScript?
- A user touch/click on a UI element (Correct answer)
- A long press gesture
- A swipe gesture
- A double-tap gesture
Correct answer: A user touch/click on a UI element
The `tap` event fires when a user taps (clicks) a NativeScript UI element, equivalent to a click event on the web.
Question 5: Which NativeScript component shows indeterminate loading progress?
- ActivityIndicator (Correct answer)
- ProgressBar
- Spinner
- LoadingView
Correct answer: ActivityIndicator
ActivityIndicator displays a spinning native loading indicator (indeterminate progress) on iOS and Android.
Question 6: What attribute makes a Button disabled in NativeScript XML?
- isEnabled='false' (Correct answer)
- disabled='true'
- enabled='false'
- active='false'
Correct answer: isEnabled='false'
Setting `isEnabled='false'` on a NativeScript Button disables interaction and typically grays it out.
What property controls the orientation of a StackLayout?