https://kotlinlang.org logo
Docs
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
  • j

    Jayalakshmi Android

    01/09/2023, 12:32 PM
    how to get information wears os is watch shape is square or rounded in jetpack compose ui
    s
    c
    • 3
    • 2
  • k

    Kiprop Victor

    01/09/2023, 2:55 PM
    Hey, I have a compose multi-platform issue that would love some help on.
    • 1
    • 1
  • z

    zt

    01/09/2023, 6:14 PM
    I'm using the androidx-paging compose library with a LazyColumn, but it keeps losing its scroll position when navigating away. I have the following code
    val videos = viewModel.videos.collectAsLazyPagingItems()
    
    LazyColumn(
        modifier = Modifier
            .fillMaxSize()
            .padding(horizontal = 14.dp),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.spacedBy(10.dp)
    ) {
        items(
            items = videos,
            key = { it.id }
        ) { video ->
            if (video == null) return@items
    
            VideoCard(video)
        }
    }
    z
    • 2
    • 6
  • t

    Thomas Dougherty

    01/09/2023, 9:23 PM
    https://issuetracker.google.com/issues/264352353
  • t

    Thomas Dougherty

    01/09/2023, 9:25 PM
    ^ I’m getting this issue where i get an IllegalArgumentException : Cannot round NaN value. It happens across devices/android versions/etc. I cannot replicate locally and the crash doesn’t indicate that it’s related to any of the components in my class. I’m using Inter-op with a fragment. The users that do seem to get this crash get it consistently, as in they crash, re-open, go through the flow, and crash again. Has anyone seen this issue, or have any ideas of what it could be?
    • 1
    • 1
  • z

    zsperske

    01/09/2023, 10:13 PM
    I am trying to create a row with 2 pieces of text, where one is aligned to the start & the other to the end. Additionally I want each piece of text to have a minimum size of 100.dp. However when I try to do that, the first piece of text tramples over the other and ignores the minimum width. What am I doing wrong?
    Row(modifier = Modifier.fillMaxWidth().padding(8.dp),
            verticalAlignment = CenterVertically,
            horizontalArrangement = Arrangement.SpaceBetween) {
            Text(modifier = Modifier.defaultMinSize(minWidth = 100.dp), text = "Some text that gets really long and keeps going and going", overflow = TextOverflow.Ellipsis, maxLines = 1)
    
            Text(modifier = Modifier.defaultMinSize(minWidth = 100.dp), text = "Other text that gets really long", overflow = TextOverflow.Ellipsis, maxLines = 1)
          }
    f
    l
    s
    • 4
    • 7
  • u

    ursus

    01/09/2023, 10:16 PM
    Why is
    Surface
    as a root composable in every example? Isn’t it supposed to be some sort of
    Background
    (which doesnt exist in material theme)? (also, why not expose the
    BoxScope
    in the content lambda? Now I need to add another needless
    Box
    if I need alignment)
    m
    f
    • 3
    • 11
  • z

    zt

    01/10/2023, 12:15 AM
    Are there plans to add params to Scaffold for passing in side composables such as the navigation rail or a drawer?
    l
    j
    • 3
    • 2
  • l

    Lucas Kivi

    01/10/2023, 12:38 AM
    I have a button with conditional content:
    CircularProgressIndicator
    and
    Text
    . I want the button to stay the same size across content changes. This is easy enough if we just convert the text size in
    Sp
    to
    Dp
    and set the
    CircularProgressIndicator
    ’s size padding accordingly. However, when we consider that the text may become multiple lines when font size is increased for accessibility this solution no longer works. I am considering building a
    SubcomposeLayout
    implementation that measures the
    Text
    and sets the button height accordingly and then can conditionally forego placing the
    Text
    . This seems a little computationally expensive. I don’t think
    Intrinsics
    will solve my problem. Does anyone have a suggestion for me before I build out my abstract
    SubcomposeLayout
    solution?
    f
    a
    a
    • 4
    • 26
  • j

    Justin Xu

    01/10/2023, 1:22 AM
    Hi all, very new to compose ui. I have a list of users displayed, with the option of expanding each user to display things like the user's nickname, status, etc. This data only needs to be updated from backend when it needs to be displayed on user click, so does it make the most sense to just call a suspending function every time it needs to be displayed, or use some sort of flow? Thanks
    l
    • 2
    • 8
  • s

    sen

    01/10/2023, 3:18 AM
    Is there a way to remove the context menu completely from TextFields?
  • s

    sen

    01/10/2023, 3:45 AM
    When creating a
    Popup
    and attempting to resize the window, the
    Popup
    is not removed unlike other applications. This appears to be the default behavior? Is there any work around to hide the
    Popup
    when the user tries to resize the window, as it causes the
    Popup
    to be in the improper place (technically the "right" place, but it shouldn't be there).
    z
    • 2
    • 4
  • v

    Vrihas Pathak

    01/10/2023, 10:25 AM
    Hi all, does anyone has any idea what is the difference between "returning a modifier using
    then()
    " and "returning a modifier directly" while creating a custom modifier?
    s
    l
    m
    • 4
    • 3
  • h

    Hasan Nagizade

    01/10/2023, 12:06 PM
    how to popBackStack with popUpTo ?
    f
    • 2
    • 28
  • z

    Zaki Shaikh

    01/10/2023, 2:11 PM
    Hi everyone, I am working on an app using Jetpack Compose GoogleMap in which i am drawing polygon by user input it is working fine but has a performance issue it is leading to a UI Junk and can't render plolygon seamlessly by user touch input. Code in thread.
    m
    c
    • 3
    • 13
  • o

    Omkar Amberkar

    01/10/2023, 3:56 PM
    I am playing around with surfaceview and compose and I often land into this issue where the surfaceview is disconnected from the surface randomly. Can someone look into this
    java.lang.IllegalArgumentException: detached
        at MobilePlayerViewModel$createSurfaceViewOnAttachStateChangeListener$1.onViewDetachedFromWindow(MobilePlayerViewModel.kt:356)
        at android.view.View.dispatchDetachedFromWindow(View.java:21362)
        at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3949)
        at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:5785)
        at androidx.compose.ui.viewinterop.AndroidViewHolder.setView$ui_release(AndroidViewHolder.android.kt:95)
        at androidx.compose.ui.viewinterop.AndroidViewHolder$layoutNode$1$4.invoke(AndroidViewHolder.android.kt:310)
        at androidx.compose.ui.viewinterop.AndroidViewHolder$layoutNode$1$4.invoke(AndroidViewHolder.android.kt:307)
        at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:420)
        at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
        at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
        at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
        at androidx.compose.ui.node.LayoutNode.detach$ui_release(LayoutNode.kt:432)
        at androidx.compose.ui.node.LayoutNode.onChildRemoved(LayoutNode.kt:314)
        at androidx.compose.ui.node.LayoutNode.removeAt$ui_release(LayoutNode.kt:288)
        at androidx.compose.ui.node.UiApplier.remove(UiApplier.android.kt:35)
        at androidx.compose.runtime.ComposerImpl$realizeMovement$1.invoke(Composer.kt:3835)
        at androidx.compose.runtime.ComposerImpl$realizeMovement$1.invoke(Composer.kt:3835)
        at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:808)
        at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:839)
        at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:995)
        at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)
        at androidx.compose.runtime.Recomposer$HotReloadable.clearContent(Recomposer.kt:385)
        at androidx.compose.runtime.Recomposer$RecomposerInfoImpl.saveStateAndDisposeForHotReload(Recomposer.kt:369)
        at androidx.compose.runtime.Recomposer$Companion.saveStateAndDisposeForHotReload$runtime_release(Recomposer.kt:1285)
        at androidx.compose.runtime.HotReloader$Companion.saveStateAndDispose(Composition.kt:1136)
        at dalvik.system.VMDebug.nativeAttachAgent(Native Method)
        at dalvik.system.VMDebug.attachAgent(VMDebug.java:656)
        at android.app.ActivityThread.attemptAttachAgent(ActivityThread.java:4220)
        at android.app.ActivityThread.handleAttachAgent(ActivityThread.java:4230)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2296)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7898)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
    i
    z
    • 3
    • 6
  • u

    ursus

    01/10/2023, 4:09 PM
    I’m debugging
    collectAsState()
    vs
    collectAsStateWithLifecycle()
    on a viewmodel state in a app where screens are fragments. I found out, surprisingly, that they behave the same. If I push a new fragment, then the current fragment’s view gets destroyed, therefore compose “instance” there dies, and nothing is collected (observed), so no need for the
    withLifecycle
    Guess that is nice and ultimately expected. However, what I found as well, is that the state collection stops as well when app goes to background (still using
    collectAsState, not the withLifecycle
    How is this possible? Does compose have some implicit hooks into the
    Activity
    ? Since in this case the fragment’s view does not get destroyed
    m
    d
    • 3
    • 26
  • h

    Håkon Pettersen

    01/10/2023, 6:35 PM
    Does anyone here have any experience or good suggestions with using Compose navigation with Dagger2? So far I have followed this article, but what I am struggeling with is providing dependencies from our main module to the new module.
    p
    m
    • 3
    • 3
  • z

    zsperske

    01/10/2023, 9:19 PM
    Does anyone have any experience/recommendations for how to implement something like the TouchDelegate you could implement in the view world? I have a material checkbox that I want to be able to align to the leading edge of (not the padding).
    Modifier.minimumTouchTargetSize()
    expands the actual size of the component
    a
    • 2
    • 3
  • u

    ursus

    01/10/2023, 9:44 PM
    How does compose know not to recompose on background? Does somehow automatically hook into
    Activity
    lifecycle?
  • g

    Gonzalo Renedo

    01/10/2023, 10:10 PM
    how to change height in composable while scrolling other composable?
    j
    • 2
    • 1
  • c

    Carl Benson

    01/11/2023, 8:14 AM
    In an immersive app, with transparent system bars being visible with swipe from bottom, how do I keep them from appearing when I show a popup or a dialog? The UI looks jumpy and whenever a dialog/popup shows since it is resized in the background.
  • m

    Moritz Post

    01/11/2023, 11:25 AM
    i have a best pracitice question: when having a state that could be null from eg when observing a viewMode, in a composable using the
    by
    delegate, how do you deal with the case that the value is null? An
    if
    check is an option but the value can not be smart-cast. What are you doing in that case? Example:
    val user by viewModel.user.collectAsState(null)
    
    if (user != null) {
      // user? can not be cast to user?
    }
    For one observable flow you could also
    let
    but that is very cumbersome when multiple values should be consumed. Any tips?
    c
    m
    • 3
    • 4
  • g

    Guilherme Delgado

    01/11/2023, 12:47 PM
    Hi guys! I’ve a
    LazyColumn
    with
    stickyHeader
    and
    itemsIndexed
    . To build it I’m using
    .forEach { (header, data) ->
    . Let’s say I would have a “today” button, how can I scroll to a desired
    stickyHeader
    position making it the first item visible? As far as i know I don’t have access to
    stickyHeader
    indexes 🤔
    o
    • 2
    • 2
  • o

    Omkar Amberkar

    01/11/2023, 2:01 PM
    Is there a way to clear the hiltViewmodel manually? How does navController clear the viewmodel upon popup?
  • t

    Tobias Preuss

    01/11/2023, 3:20 PM
    What is the Compose UI equivalent of
    com.google.android.material.textfield.TextInputLayout
    incl. hint outline, character limit text, error handling? Is there any recommendable open source library out there?
    t
    a
    • 3
    • 17
  • c

    CLOVIS

    01/11/2023, 3:21 PM
    Do
    Applier
    implementations need to be thread-safe? e.g. is it safe to create a
    Node
    implementation that uses an
    ArrayList
    to store its children?
    j
    • 2
    • 1
  • l

    Landry Norris

    01/11/2023, 3:31 PM
    ChatGPT uses an archive from 2021 for its training, and currently does not have access to the up-to-date web. I would be wary of anything it says about Compose.
    a
    k
    • 3
    • 6
  • t

    Tolriq

    01/11/2023, 7:08 PM
    Where the new compose release docs released before the artifacts or is there a publish issue that will be fixed later?
    j
    • 2
    • 6
  • l

    Landry Norris

    01/11/2023, 8:15 PM
    I recently set up tests for a Compose app. The tests pass on my emulator and Pixel 5, but when I run on Firebase Test Labs, I get the following error. I don’t see any of my code in the stacktrace. Is there something I need to do differently for tests?
    java.lang.IllegalStateException: calling recordModificationsOf and applyChanges concurrently is not supported
Powered by Linen
Title
l

Landry Norris

01/11/2023, 8:15 PM
I recently set up tests for a Compose app. The tests pass on my emulator and Pixel 5, but when I run on Firebase Test Labs, I get the following error. I don’t see any of my code in the stacktrace. Is there something I need to do differently for tests?
java.lang.IllegalStateException: calling recordModificationsOf and applyChanges concurrently is not supported
View count: 15