0
0
Android Kotlinmobile~10 mins

Why layout mastery creates professional UIs in Android Kotlin - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a vertical LinearLayout in Android XML.

Android Kotlin
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="[1]">
</LinearLayout>
Drag options to blanks, or click blank then click option'
Astack
Bhorizontal
Cgrid
Dvertical
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'horizontal' instead of 'vertical' causes the layout to arrange items side by side.
2fill in blank
medium

Complete the Kotlin code to set a TextView's width to match its parent.

Android Kotlin
val textView = TextView(this)
textView.layoutParams = LinearLayout.LayoutParams([1], LinearLayout.LayoutParams.WRAP_CONTENT)
Drag options to blanks, or click blank then click option'
ALinearLayout.LayoutParams.FILL_PARENT
BLinearLayout.LayoutParams.WRAP_CONTENT
CLinearLayout.LayoutParams.MATCH_PARENT
DLinearLayout.LayoutParams.WRAP_PARENT
Attempts:
3 left
💡 Hint
Common Mistakes
Using WRAP_CONTENT causes the TextView to shrink to its text size.
3fill in blank
hard

Fix the error in the ConstraintLayout XML to center a Button horizontally.

Android Kotlin
<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintStart_toStartOf="[1]"
    app:layout_constraintEnd_toEndOf="parent" />
Drag options to blanks, or click blank then click option'
Aparent
Blayout
Cbutton
Dconstraint
Attempts:
3 left
💡 Hint
Common Mistakes
Setting start constraint to the Button itself causes a circular reference error.
4fill in blank
hard

Fill both blanks to create a FrameLayout with a TextView aligned bottom right.

Android Kotlin
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="[1]|[2]"
        android:text="Hello" />
</FrameLayout>
Drag options to blanks, or click blank then click option'
Abottom
Bright
Ccenter
Dleft
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'center' or 'left' will position the TextView incorrectly.
5fill in blank
hard

Fill all three blanks to create a ConstraintLayout Button centered vertically and horizontally with margin.

Android Kotlin
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="16dp"
    app:layout_constraintTop_toTopOf="[1]"
    app:layout_constraintBottom_toBottomOf="[2]"
    app:layout_constraintStart_toStartOf="[3]"
    app:layout_constraintEnd_toEndOf="parent"
    android:text="Click Me" />
Drag options to blanks, or click blank then click option'
Aparent
Dbutton
Attempts:
3 left
💡 Hint
Common Mistakes
Using the Button's own id causes constraint conflicts.