https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
compose
  • l

    loloof64

    07/21/2022, 5:17 PM
    Why in this simple experiment, the square is not updated when it is clicked ? Though I'm pointing to the last element of the list in the Text
    Number Square experiment.txt
    l
    • 2
    • 25
  • c

    Can Korkmaz

    07/21/2022, 5:42 PM
    Hello, I'm having problem with using downloaded custom fonts with FontStyles. App crashes on both emulator and physical device. It also crashes when I comment out the textStyle assignation and any resource getter (colorResource), but it won't crash with a simple red Box.
    Cannot create Typeface from ResourceFont(resId=2131296260, weight=FontWeight(weight=400), style=Normal)
    s
    • 2
    • 10
  • d

    David Corrado

    07/21/2022, 7:35 PM
    Is there a way in compose to define an Image fun where you only provide the height and width of the image and not of the view 🧵
    f
    • 2
    • 6
  • n

    Ngọc Nguyên Nguyễn

    07/22/2022, 2:48 AM
    Hello, Why does my screen jump when the keyboard is displayed Can I handle it? And how to check the keyboard showed?
    screen-20220722-094151.mp4
    z
    • 2
    • 5
  • v

    Vivek Modi

    07/22/2022, 10:03 AM
    Hey guys, what is correct behaviour of loading next compose function to using compose navigation. I am using State Ui event to emit ui event. My
    navigateToResultScreen
    is calling twice with screen flicks. Is it correct behaviour? MainActivity.kt
    when (val state = viewModel.stateResultFetchState.collectAsState().value) {
        is ResultFetchState.OnSuccess -> {
            LaunchedEffect(Unit) {
                navigateToResultScreen(state.nearestResult)
            }
        }
        is ResultFetchState.IsLoading -> {
            LoadingFunction()
        }
        is ResultFetchState.OnError,
        is ResultFetchState.OnEmpty -> {
            ActivityContent(viewModel)
        }
    }
    • 1
    • 1
  • a

    Akhil Jain

    07/22/2022, 10:52 AM
    Hello guys. I have a small doubt. In the below code, I have written a function
    AudioWidgetItem
    and I am passing a lambda
    onPostClicked
    in it. Now when I am invoking this lambda on
    line 149
    then this function is getting recomposed again and again on some action (even though hash code of this lambda is coming same as printed in
    line 144
    ). But when I am commenting out this lambda invocation at
    line 149
    then unnecessary recomposition of this function doesn't happen. I am not able to understand the reason behind this behaviour
    s
    n
    • 3
    • 5
  • b

    Bradleycorn

    07/22/2022, 1:34 PM
    👋 Hi Everyone! I’ve setup some instrumentation tests, but when I try to run them, I get the following error:
    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myapp.android.test/androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity}
    Anyone run into this before? I’ve found a few things that mention adding the activity to the manifest in your androidTest folder, but I don’t have a manifest there, and have never needed one before. Not sure why I would need one now …
    :not-kotlin: 1
    n
    • 2
    • 8
  • c

    Colton Idle

    07/22/2022, 1:45 PM
    Am I going crazy, or can I not use a mutableStateOf<Boolean> in AnimatedVisibility?
    AnimatedVisibility(visibleState = (viewModel.screenState.loadingInProgress))
    d
    • 2
    • 3
  • d

    deviant

    07/22/2022, 2:17 PM
    hey guys does compose support shared element transition animations? can't find it in the docs
    t
    z
    +2
    • 5
    • 8
  • n

    nglauber

    07/22/2022, 2:31 PM
    hey guys. can someone help me with unit tests in Compose + Coil image loading? I answered my own question here and I would like to know if I’m doing right… https://stackoverflow.com/questions/73044642/how-to-unit-test-if-an-image-was-loaded-using-coil-compose/73080538#73080538
    y
    • 2
    • 6
  • l

    Landry Norris

    07/22/2022, 4:46 PM
    I’ve run into a build error I don’t quite understand. Whenever I use
    PointerInputChange#isConsumed
    , I get an error
    This API is experimental and is likely to change in the future.
    I don’t see any errors in the IDE, and opting in to ExperimentalComposeApi and ExperimentalMaterialApi don’t fix it. Looking at the source, I also don’t see it marked as experimental.
    i
    i
    • 3
    • 3
  • d

    David Corrado

    07/22/2022, 4:58 PM
    Anyone know how to make compose where you have 2 different texts with large text work more like if you did it with the layout system or at least where the second text does not disappear. 🧵
    f
    r
    +2
    • 5
    • 13
  • z

    zt

    07/22/2022, 5:05 PM
    Right now I have all my screens contained inside one scaffold, using a destinations nav host from the compose destinations library. Would it be better to change this so that each screen provides it's own scaffold?
  • p

    Paul Woitaschek

    07/22/2022, 8:27 PM
    Is there any way to capture a node to a bitmap with the node being larger than the current window?
    c
    • 2
    • 6
  • s

    spierce7

    07/23/2022, 5:43 AM
    I’ve been trying out Voyager for Compose navigation. One of the interesting pieces is the concept of `Screen`s.
    Screen
    s use classes, but I haven’t found any way to use the benefits of classes in my Composable functions. Everything is scoped to the Compose lifecycle, i.e. my ScreenModel’s via
    rememberScreenModel
    , and so instead of being able to share it as a member variable between all my Composable functions, I’m stuck passing it from Compose function to Compose function. It’s very cumbersome. Is there something that I’m overlooking? Is there a better way to do this?
  • s

    Slackbot

    07/23/2022, 12:53 PM
    This message was deleted.
    c
    • 2
    • 2
  • s

    Saiedmomen

    07/23/2022, 1:17 PM
    How can we enable compose metrics and
    @Stable
    inference in multiplatform modules with android soucesets? There are no composables in the module. I have tried adding the following to the
    android
    block but doesn't seem to work and metrics report isn't generated for the module I am following Chris Banes blogpost on the issue and reports are generated for the main app module
    android {    
        ...
        buildFeatures {
            compose = true
        }
        composeOptions {
            kotlinCompilerExtensionVersion = libs.versions.compose.get()
        }
    }
    a
    z
    +2
    • 5
    • 13
  • j

    Jasmin Fajkic

    07/23/2022, 1:23 PM
    What is easiest way to add icon over other element . I want to make this layout and have hard time to put bulb like position absolute on comment box
    m
    • 2
    • 1
  • l

    loloof64

    07/23/2022, 3:43 PM
    Hi. I'm using Android Studio Chipmunk. I can't call `viewModel()`in a `@Composable`parameter, though I've added the dependency
    androidx.lifecycle:lifecycle-viewmodel-compose:2.5.0
    to build.gradle file of the app module. Why ? (I keep getting the error "Expression 'viewModel' of type 'StockfishLibraryViewModel' cannot be invoked as a function. The function 'invoke()' is not found")
    i
    • 2
    • 11
  • s

    spierce7

    07/24/2022, 5:05 AM
    I like to divide my screens up into smaller private `Composable`s. I find it very cumbersome passing my dependencies around to all the different `Composable`s for a given screen. You have the state, and then any ViewModel’s that they might reference. I find myself 3 or 4 `Composable`s / functions deep, and I’m having to pass a ViewModel along every step of the way. It’s pretty annoying. Is there a cleaner way to do this that I’m just not aware of? Surely I’m not the only one to find this frustrating.
    ➕ 1
    a
    c
    +2
    • 5
    • 12
  • j

    jasu

    07/24/2022, 9:27 AM
    any way to convert entire content of lazy list composable to an image? Like screenshot of a scrollView?
  • a

    Arkadii Ivanov

    07/24/2022, 12:29 PM
    I'm playing with the new
    LookaheadLayout
    , and it crashes if there is
    LazyColumn
    inside `LookaheadLayout`'s content:
    java.lang.IllegalStateException: subcompose can only be used inside the measure or layout blocks
    Is it not supported yet, or am I doing something wrong?
    s
    z
    d
    • 4
    • 4
  • j

    Jasmin Fajkic

    07/24/2022, 7:35 PM
    Dumb question. I have both light and dark colors scheme and theme setup but when i switch to dark my status bar stays white. Where to change it 😞
    m
    • 2
    • 1
  • j

    james

    07/24/2022, 11:17 PM
    is there a consensus on what is “best practice” when using the Navigation Compose library? if I look around at many examples in open source projects I can see 3 methods being used: 1. Passing lambdas from the top level of the Composable hierarchy (where the NavController is), all the way down to where it’s required, eg: a. above where a NavHost is declared we see something like
    val navigateToDetailScreen: (Int) -> Unit
    declared b.
    navigateToDetailScreen
    is passed into the nav graph builder and passed into every
    composable()
    route that might need to call it c.
    navigateToDetailScreen
    is then passed through as many Composables as required until it is passed into to the Composable that will generate the action from an onClick event 2. Passing the instance of
    NavController
    from the same top level (where the NavHost is declared) down to each screen and into the ViewModel which will then keep a reference to it 3. Wrapping
    NavController
    in a custom navigator class and injecting that custom class into ViewModels where it’s required if I think about how best to build something flexible, testable, and not too “polluting” of my codebase, #3 seems like the best option, but when I look at examples of what others have built that method seems like the least common, so I find I am second guessing myself and wondering if there’s a problem with that option which I’m not seeing
    i
    c
    d
    • 4
    • 11
  • h

    harry248

    07/25/2022, 5:28 AM
    Anyone experiencing LazyColumn horizontally "elasticity" / overscroll effect in 1.3.0-alpha01?
    a
    a
    • 3
    • 3
  • c

    Clément Cardonnel

    07/25/2022, 8:15 AM
    Hello, I come from a background of iOS (SwiftUI) programming and I’m very new to Android and Jetpack Compose. I was wondering how Navigation is supposed to work in Compose. Specifically, I’m wondering how you’re supposed to send a lot of data from one screen to another. Let’s say for example that I have a screen with a list of all natural parks in the US. I fetched this list from my backend, and each park is a Park object with many details. When the user selects a park, the app navigates to a park detail screen featuring all the park informations. Now, I’ve looked at the documentation, and it looks like we can send arguments to the next screen. But these arguments look like they were designed for small strings such as an id. Not for sending a whole object. I saw someone on StackOverflow say that you could serialize the Park object into a JSON string and send it as an argument. But this doesn’t feel like a good practice and I’m wary of using it. What is the correct thing to do in this case? Multiple ideas came to mind, but I don’t know which one is best: A. Send a serialized JSON string as a navigation argument B. Send only the park’s id and fetch the park once again in the detail screen. Whether by making a brand new request or fetching it from a cache C. Pass down a view model of some sort to the detail screen. The view model being shared between the list and the detail. D. Something I didn’t think about? Thank you in advance for your help!
    m
    a
    +3
    • 6
    • 28
  • v

    vide

    07/25/2022, 8:58 AM
    It is advised not to pass viewmodel objects down to child composables, is this due to increased coupling and worse testability or are there some other reasons too? Context: Some of my screens mostly consist of "sub-screens" that definitely don't need to be reusable, would it be bad practice to just directly pass the viewmodel down a few layers of parent layout composables?
    c
    r
    c
    • 4
    • 16
  • c

    Christoph Wiesner

    07/25/2022, 1:18 PM
    Hi, i want to display a composable (some Chrome) behind a
    LazyVerticalGrid
    and that composable should match the grids height. seems like that’s not possible bc. the Grid is a SubComposeLayout and therefore i cannot use
    height(IntrinsicSize.Min)
    (i do not want / cannot inline the content into the grid) is there another approach?
    a
    • 2
    • 1
  • c

    Colton Idle

    07/25/2022, 2:57 PM
    Why does my button (which is not showing, since the entire screen is red) react to touches? Is there a way to prevent it? This is a simple example but I have more complex screens where I have some inner "screens" that overlap each other but the fact that clicks get passed through is kinda messing some things up for me.
    fun MyScreen(
    ) {
      val context = LocalContext.current
      Box(Modifier.fillMaxSize().background(Color.Green), contentAlignment = Center) {
        Button(onClick = { Toast.makeText(context, "screen in background clicked", Toast.LENGTH_SHORT).show() }) {
          Text(text = "Bottom")
        }
      }
      Box(Modifier.fillMaxSize().background(Color.Red)) {}
    }
    👀 1
    j
    m
    l
    • 4
    • 9
  • v

    Vivek Modi

    07/25/2022, 3:00 PM
    Hey guys, we were using
    xml
    for ui components which has
    id/tag
    that is used for
    automated ui testing
    . Now we switch to jetpack compose. So how can I provide this
    id/tag
    for
    automation
    now?
    l
    • 2
    • 3
Powered by Linen
Title
v

Vivek Modi

07/25/2022, 3:00 PM
Hey guys, we were using
xml
for ui components which has
id/tag
that is used for
automated ui testing
. Now we switch to jetpack compose. So how can I provide this
id/tag
for
automation
now?
l

Landry Norris

07/25/2022, 3:08 PM
Modifier.testTag("an id")
https://developer.android.com/jetpack/compose/testing
v

Vivek Modi

07/25/2022, 3:10 PM
okk sure, thanks a lot
View count: 5