AAD User Interface (UI) Design & Development — Questions and Answers
Question 1: Which XML attribute is used to set the width of a UI component in Android?
- android:width
- android:layout_width (Correct answer)
- android:component_width
- android:ui_width
Correct answer: android:layout_width
The 'layout_width' attribute is essential for defining the width of UI components in Android layouts.
Question 2: What is the purpose of ConstraintLayout in Android UI design?
- To replace LinearLayout in all cases
- To enable dynamic resizing of UI components
- To provide a responsive and flat UI design (Correct answer)
- To enforce a strict grid-based design
Correct answer: To provide a responsive and flat UI design
ConstraintLayout allows flexible and complex UI design by defining constraints between UI elements, reducing nested layouts.
Question 3: Which UI component is best suited for displaying a list of scrollable items in Android?
- ListView
- ScrollView
- RecyclerView (Correct answer)
- GridLayout
Correct answer: RecyclerView
RecyclerView is the recommended UI component for handling large datasets efficiently by reusing item views.
Question 4: Which of the following UI components is commonly used to handle user interactions such as button clicks?
- TextView
- ImageView
- Button (Correct answer)
- ProgressBar
Correct answer: Button
A Button in Android is a key UI element that responds to user interactions such as clicks.
Question 5: What is the primary advantage of using Jetpack Compose for UI design in Android?
- It replaces all existing XML layouts
- It allows creating UI declaratively with Kotlin (Correct answer)
- It enforces strict UI constraints
- It is only useful for animations
Correct answer: It allows creating UI declaratively with Kotlin
Jetpack Compose provides a modern, declarative approach to UI development, reducing boilerplate code and improving performance.
Question 6: Which method is used to programmatically update a TextView’s text content in Android?
- updateText()
- setText() (Correct answer)
- modifyText()
- changeText()
Correct answer: setText()
The setText() method is the standard approach to updating the text content of a TextView in Android.
Which XML attribute is used to set the width of a UI component in Android?