Skip to content

Calculate a custom tip: Android Basics with Compose #353

Description

@qt911025

URL of codelab

None

In which task and step of the codelab can this issue be found?

None

Describe the problem

At this chapter of the tutorial:

https://developer.android.com/codelabs/basic-android-kotlin-compose-calculate-tip?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-2-pathway-3%3Fhl%3Dzh-cn%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-calculate-tip#5

Where

"In the Switch composable, add this modifier to align the Switch composable to the end of the screen:"

   Switch(
       modifier = modifier
           .fillMaxWidth()
           .wrapContentWidth(Alignment.End),
       //...
   )

should be:

   Switch(
       modifier = Modifier
           .fillMaxWidth()
           .wrapContentWidth(Alignment.End),
       //...
   )

Because the switch component is inside a row, and the modifier passed in is for the row component.

Invoke EditNumberField just passed a 32dp bottom padding, which will add redundant bottom padding to the switch component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions