URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-compose-button-click-practice-problem?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-2-pathway-2%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-button-click-practice-problem#5
In which task and step of the codelab can this issue be found?
it's about the source code in this github repository
Describe the problem
No problem, but may I ask two questions ? if not, close&ignore this and please tell me where should I ask such questions.
- How can you add a
Text
in step 2(lemon squeeze), hopefully using a Column
, centered horizontally, below the lemon image that shows Taps left: N
without modifying the LemonTextAndImage(...)
function contents ?
I tried to use a Column
but because there's a modifier=modifier.fillMaxSize()
inside LemonTextAndImage
it occupies the whole screen, so my Text
is outside the screen / invisible.
(curiously though, modifier = modifier.fillMaxSize(0.9f)
kind of works: at least my text isn't invisible below the screen like with 1f
would)
In the following screenshot I tried using a Box
but the vertical centering is a hack(because I wouldn't know where on the screen the lemon image ends, vertically) that only works well on the preview (see Taps left: 0
there) but not on any other device (because of screen sizes difference) like in the emulator (see Taps left: 6
there).
- Is it possible to vertically center the
Text
so that it's just beneath the lemon image(and its included border), when using Box, that works on any device ? (this probably means, you've a way to detect where the lemon image ends(vertically) and place the Text right beneath that ?)
Versions
Android Studio version:
Android Studio Chipmunk | 2021.2.1 Patch 1
Build #AI-212.5712.43.2112.8609683, built on May 18, 2022
Runtime version: 11.0.12+0-b1504.28-7817840 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.17.15-gentoo-x86_64
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 12
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin (212-1.7.10-release-333-AS5457.46)
Current Desktop: LXQt
API version of the emulator:
31.2.10-8420304
Additional information
Include screenshots if they would be useful in clarifying the problem.
![hackyBoxverticalcenter_screen-2022-07-19-20-51-35](https://user-images.githubusercontent.com/106607441/179827031-bbedef17-7dbb-4763-9240-f4e51b7a34c0.jpg)
PS: I've previously mistakenly created this issue in the wrong repository here google-developer-training/basic-android-kotlin-compose-training-dice-roller#15 I'm linking to it, in case anyone else stumbles upon that one and wants a quick jump over to this one, for any possible solutions. Thank you for your understanding.