Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate a custom tip: Android Basics with Compose #230

Open
BurtCrepeault opened this issue Aug 30, 2024 · 0 comments
Open

Calculate a custom tip: Android Basics with Compose #230

BurtCrepeault opened this issue Aug 30, 2024 · 0 comments

Comments

@BurtCrepeault
Copy link

[URL of codelab]
(https://developer.android.com/codelabs/basic-android-kotlin-compose-calculate-tip)

In which task and step of the codelab can this issue be found?
Step 6: Add a switch - Task #8

Describe the problem
When strictly copied from the codelab, this step produces misaligned Text and Switch composables, even though their parent Row has a verticalAlignement argument. See Screenshot1.

This appears due to the modifier used in the Switch element, passed as an argument in the RoundTheTipRow() function. The modifier, which has a non-zero bottom padding value, is set in the call to the function inside TipTimeLayout().

Using a default modifier, like in the code below, fixes the problem:

Switch ( checked = roundUp, onCheckedChange = onRoundUpChanged, modifier = Modifier .fillMaxWidth() .wrapContentWidth(Alignment.End) )

Steps to reproduce?
Follow the codelab up to step 6, task 12, and run the app in an emulator (same results can be seen in preview)

Versions
Android Studio version: Android Studio Koala | 2024.1.1 Patch 2
API version of the emulator: Google Pixel 7 Android 14.0 ("UpsideDownCake")

Additional information
Screenshot1

I did not check if the solution code provided is correct or contains the same mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant