Complete the code to create a vertical LinearLayout in Android XML.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="[1]">
</LinearLayout>The android:orientation attribute controls the layout direction. For a vertical stack, use vertical.
Complete the Kotlin code to set a TextView's width to match its parent.
val textView = TextView(this)
textView.layoutParams = LinearLayout.LayoutParams([1], LinearLayout.LayoutParams.WRAP_CONTENT)To make the TextView fill the parent's width, use MATCH_PARENT.
Fix the error in the ConstraintLayout XML to center a Button horizontally.
<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" />To center horizontally, both start and end constraints must point to parent.
Fill both blanks to create a FrameLayout with a TextView aligned bottom right.
<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>To align the TextView at the bottom right, use bottom and right in layout_gravity.
Fill all three blanks to create a ConstraintLayout Button centered vertically and horizontally with margin.
<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" />To center the Button, all constraints must point to parent.