WorksheetsMobile App 2
Total questions: 40
Worksheet time: 20mins
In a View element in a Layout XML, which two attributes are required?
android:id and android:orientation
android:layout_width and android:layout_height
android:text and android:padding
android:gravity and android:layout_weight
What is android:id mainly used for in Layout XML?
Set the size of a View
Determine the layout orientation
Refer to find a View via findViewById()
Assign display text
Where are layout XML files located in an Android project?
res/layout
res/drawable
res/raw
res/menu
Which statement correctly describes “Layout” in Android?
It’s just a type of TextView
It’s a way to organize Views inside the UI
It can only be created via WYSIWYG
It cannot be nested
In the example, which namespace declaration appears at the top of the layout XML?
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:kotlin="http://schemas.android.com/kotlin"
In LinearLayout, which attribute defines the orientation of children?
android:orientation
android:gravity
android:layout_weight
android:layout_gravity
In the LinearLayout exercise, which attribute is used to “weight” space among children?
android:layout_weight
android:weightSum
android:layout_margin
android:padding
What is TRUE about FrameLayout per the slide?
Can contain at most one child
Supports multiple layers (Z-order) and first child is at the bottom
Does not support child margins
Does not support gravity
Which statement correctly describes FrameLayout’s Z-order?
Last child is at the bottom
First child is at the bottom
All children are on the same layer
No layer concept
How is RelativeLayout described in the slide?
Positions children absolutely by pixels only
Children are relative to parent and/or to each other
Does not support multiple layers
Has only one child
According to the slide, which of the following is in “Popular Layout Classes”?
ConstraintLayout
RelativeLayout
TableLayout
CoordinatorLayout
Where does ViewPager appear in the slides?
In the “Popular Layout Classes” list
In the FrameLayout example
In the RelativeLayout example
In the Raw data section
Which statement correctly describes the relationship between ViewGroup and View?
A View contains a ViewGroup
A ViewGroup contains Views
Each ViewGroup has only one child View
View and ViewGroup are the same
In the layout example, what is the TextView’s text value?
“Hello World!”
“Is Android a Linux Distribution?”
“Welcome to Android”
“Sample Text”
According to the slide, how can a Layout be created/edited?
Only manually via XML
Only by Java/Kotlin code
By code or WYSIWYG or manual editor
Only by drag-and-drop tools
Which value is used for padding in the layout example?
16sp
16px
16dip
16pt
In the LinearLayout exercise, which resource reference is used to draw a divider?
@raw/divider
@menu/divider
@drawable/divider
@values/divider
According to the slides, which items are listed alongside “Layouts” and “ViewPager” in the topic headers?
Notifications and Services
Values and Drawables
DataBinding and Navigation
Broadcasts and Content Providers
Which statement is TRUE about RelativeLayout per the slides?
Has no multi-layer concept
Only allows constraints to parent, not siblings
Can have Z-order layers like Photoshop
Cannot size children relatively
According to the slide headers, besides Layouts what other topics are mentioned?
Raw data and Menu
Permissions and Gradle
WorkManager and Hilt
CameraX and ML Kit
In a Layout XML file, which attributes are required for every View?
android:layout_width và android:layout_height
android:id và android:layout_width
android:orientation và android:layout_height
android:textAppearance và android:id
What does “Containers (ViewGroups) contain Views” mean?
ViewGroups contain Views such as TextView, ImageView, Button
Views contains ViewGroups
Only RelativeLayout can contain View
Only LinearLayout can contain View
Which of the following is NOT among the listed “Popular Layout Classes”?
FrameLayout
LinearLayout
RelativeLayout
ConstraintLayout
Which statement is correct about the z-order stacking in FrameLayout?
The first child will be at the bottom
The last child will be at the bottom
The children cannot overlap
FrameLayout does not support gravity
In the LinearLayout exercise, how do you make a View take the remaining space?
android:layout_width="match_parent"
android:layout_width="0px" and android:layout_weight="1"
android:layout_height="match_parent"
android:layout_weight="0"
Which folder contains XML drawables?
res/drawable
res/drawable-xxhdpi
res/xml
assets/drawable
Where should bitmap drawables (PNG/JPEG) be placed?
res/drawable-*dpi
res/drawable
res/raw
res/menu
How do you set an image for an ImageView from a drawable?
android:src="@drawable/name"
android:background="@drawable/name"
android:icon="@drawable/name"
android:sourceUri="@drawable/name"
How to set a background image for any View?
android:src="@drawable/name"
android:background="@drawable/name"
android:icon="@drawable/name"
android:drawableTop="@drawable/name"
Which characteristic is correct about 9-patch drawables?
9.png lets you specify stretchable areas and padding
9-patch does not support transparency
9-patch is only for JPEG
9-patch must be placed in res/raw
Which step helps you verify the Vietnamese translation for string values?
Switch the phone language to Vietnamese and check the UI
Rename package to “.vi”
Rebuild project in Release mode
Move strings.xml to res/raw
What orientation does the root LinearLayout use in the example?
vertical
horizontal
grid
no orientation
Which attribute is set for the question TextView in the example?
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="italic"
android:textSize="20sp"
android:fontFamily="serif"
Which spacing attribute appears on the inner LinearLayout in the example?
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:paddingTop="16dp"
android:layout_marginTop="16sp"
In the LinearLayout exercise, which element is used as a vertical divider?
A View with width="1px", height="match_parent", background="@drawable/divider"
TextView with text="|"
ImageView with src as a line image
Button with transparent background
Which statement is correct about android:id in Layout XML?
It is optional and used for findViewById later
Is a required attribute for every View
Applies to TextView only
Must start with “@android:”
RelativeLayout belongs to which group in the Android UI hierarchy?
View
ViewGroup
Drawable
Resource
Which topics appear together in the “Android Resources” slide navigation?
Layouts, ViewPager, Values, Drawables, Raw data, Menu
Activities, Services, Broadcast, ContentProvider
Networking, Sensors, Maps, Camera
Testing, NDK, JNI, ProGuard
Which capability is supported by FrameLayout?
Supports child margins and gravity
No overlapping support
Only 1 child required
Only padding supported, no margins
Which snippet matches the ImageView in the FrameLayout example?
<ImageView android:id="@+id/imageView" android:layout_width="wrap_content" />
<ImageView android:id="@+id/picture" android:layout_width="match_parent" />
<ImageView android:id="@+id/imageView" android:layout_width="match_parent" />
<ImageView android:id="@+id/img" android:layout_width="wrap_content" android:src="@drawable/x" />
