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
  • l

    Louis

    10/20/2021, 12:26 PM
    I am using systemuicontroller for changing navigation bar and status bar colors. I succeed but as you see in screenshot I cannot change the color icons even by putting true or false for the darkIcons parameter. What I’m doing wrong?
    • 1
    • 1
  • a

    Arpit Shukla

    10/20/2021, 1:23 PM
    Hey guys, Is there some way to draw only behind the status bar and not behind the navigation bar while going edge-to-edge? Right now I am using a workaround by adding a
    navigationBarsPadding
    modifier for my entire app content. But is there any other way?
    c
    • 2
    • 2
  • r

    rattleshirt

    10/20/2021, 3:01 PM
    Hi, is it possible for
    LazyRow
    items (with content image / title / max 3 lines) to fill to the height of the
    LazyRow
    ?
    fillParentMaxHeight
    doesn’t seem to work
    c
    • 2
    • 4
  • c

    Chris Johnson

    10/20/2021, 3:23 PM
    I'm probably missing the reason the compiler is angry about using the
    composed
    modifier here.
    @SuppressLint("UnnecessaryComposedModifier")
    @Stable
    fun Modifier.clickableNoIndication(onClick: () -> Unit): Modifier = composed {
        clickable(onClick = onClick, indication = null, interactionSource = remember { MutableInteractionSource() })
    }
    I have to add the suppression otherwise it complains. But if I don't use it, I can't use remember. Am I missing something simple?
    ➕ 1
    l
    • 2
    • 2
  • l

    Lucca Beurmann

    10/20/2021, 8:52 PM
    Hello everyone, i'm facing a problem with LazyVerticalGrids that causes my app to crash. I'm using a LazyGrid to display a list of photos (receiving the image url from an api and loading in my view using Glide) that can be cleared whenever the user sends a request with a differente filter, but when the list is cleared my application crashes with an Index out Of Bounds Exception
    d
    c
    +2
    • 5
    • 14
  • j

    james

    10/20/2021, 10:10 PM
    this might be a really obvious and common recomposition issue, but can anyone point me in the right direction with this? • large list of data being loaded by LazyColumn (fills max height of screen) • when scrolling down, scroll is smooth and fast with no issues • when scrolling up, if any of the items in LazyColumn are taller than the screen itself, the scroll looks like it jitters and kind of gets “stuck” when it tries to scroll past those items • this jittering does not occur scrolling past smaller items, in that case going up is just as smooth as going down.. it’s only with taller items it feels like maybe recomposition is occurring, but I don’t quite understand it. any tips? does this sound familiar to someone?
    👀 1
    w
    a
    +3
    • 6
    • 16
  • a

    Aleksey Chugaev

    10/21/2021, 5:37 AM
    Hello everyone, I'm having an issue with an
    OutlinedTextField
    if I try to use it for number input only and restrict it to 2 digits after the decimal separator, see code in thread
    d
    • 2
    • 4
  • m

    Matti MK

    10/21/2021, 7:07 AM
    Is there an established convention for handling different status bar colors for different screens? Currently I’m changing the colors with the Accompanist
    System UI Controller
    on the root of every screen
    m
    • 2
    • 6
  • i

    Ink

    10/21/2021, 8:28 AM
    I want to change black color to red but when I set tint also purple element goes to red. Is it possible to change only black elements? That image is vector .xml
    Image(
        painter = painterResource(id = R.drawable.wifi),
        contentDescription = "",
        colorFilter = ColorFilter.tint(Color.Red)
    )
    c
    d
    • 3
    • 3
  • a

    Anthony Martin

    10/21/2021, 8:28 AM
    How do we test resources with Compose UI Testing? I have a valid context with:
    InstrumentationRegistry.getInstrumentation().targetContext
    Then calling the resulting
    context
    with
    getString(R.string.app_name)
    returns: Using
    Method threw 'android.content.res.Resources$NotFoundException' exception.
    It does this in my project along with the default compose template project in Android Studio. It would be handy if we had resources to test since we can then test multiple languages with UI tests and produce screenshots for this to send to our QA team as part of a release build. One project is using the latest alpha version, and the other is using the latest stable version.
    a
    • 2
    • 3
  • g

    Geert

    10/21/2021, 9:14 AM
    Im getting errors while loading images on some devices.
    java.lang.RuntimeException: Canvas: trying to draw too large(105294960bytes) bitmap.
    is there a way to fix this? I also tried accomponist
    m
    • 2
    • 1
  • l

    louiscad

    10/21/2021, 10:18 AM
    Hello, I'm using the deep link trick to navigate to a composable from a notification, and there's an issue I'm having that I didn't have when I was using separate activities and pendingintents without deeplinks: The state of the previous destination is always lost on navigating from the link, the entire activity being destroyed, even after navigating multiple times from the very same deep link uri. I'd like to not have that useless recreation and state loss happen when the deep link points to the destination already on top. Is that possible at the moment, or shall I file a feature request? Note that I specified
    android:launchMode="singleTop"
    in the
    AndroidManifest.xml
    for the host Activity.
    i
    • 2
    • 2
  • z

    Zoltan Demant

    10/21/2021, 10:30 AM
    Would it be a bad idea to use
    animateXYZAsState
    in a composable thats used literary everywhere? Use-case: Its a Text composable, and Id like to animate changes to its state (dim, highlight, etc).
    d
    • 2
    • 1
  • a

    Albert Francis

    10/21/2021, 11:32 AM
    Hey, I have
    HorizontalPager
    with
    x many
    items (can be 1 can be 20+) and each one of the item needs to call a BackEnd to fill it's information. So every time i receive a pageIndex i call
    viewmodel.getMeSomeCake(index)
    and when i receive it i want to fill the screen. I want to use StateFlow but i got the same problem as if it's a fragment with ViewPager. Pager creates the
    n-1
    ,
    n
    ,
    n+1
    pages so the data i got is not the one for the visible page. is there any recommended ways to do it on compose?
    c
    • 2
    • 4
  • t

    Tgo1014

    10/21/2021, 12:11 PM
    Can we already use Material You with Compose?
    c
    • 2
    • 1
  • r

    raenardev

    10/21/2021, 12:24 PM
    If im using
    Canvas
    composable i have access to its size inside
    DrawScope
    . I want to use this size to create
    Path
    and then clip it out. However, i shouldn’t allocate Path object there, right? So i want to use
    remember
    , but i can’t in
    DrawScope
    . Am i missing something, or the only way to do this is to measure constraints outside of Canvas, create Path with remember, and then use it inside DrawScope?
    👀 1
    d
    • 2
    • 1
  • h

    Henning B

    10/21/2021, 12:44 PM
    So I want to use mutableStateOf in my ViewModel like this:
    private var _state: State by mutableStateOf(Loading)
        override val state: State = _state
    
        fun onLoadClicked() {
            _state = Loading
            viewModelScope.launch {
                _state = when (val content: Content? = loadData()) {
                    null -> Error
                    else -> PresentData(content)
                }
            }
        }
    So now I would like to test the behaviour of onLoadClicked. But I do not know how to verify that calling that function sets the state to Loading and than to PresentData/Error. I could observe a liveData and remember all states is was set to but how do I do it with mutableStateOf?
    ✅ 1
    m
    a
    • 3
    • 5
  • m

    mattinger

    10/21/2021, 2:19 PM
    So, i’m looking to put some logging into a NavHostController. I started with a state object that has an empty route string, and then a destination listener that updated the state object’s route string. The problem then is that i want to listen to the state object and do some logging as it changes. I tried a SideEffect, but for whatever reason, it’s only getting called a single time with the initial version of the state. When i create the nav graph i would have assumed that it would update the state (which it does), but it never triggers the side effect for that first update (subsequent updates work fine).
    :thread-please: 1
    i
    • 2
    • 17
  • b

    Brian G

    10/21/2021, 2:29 PM
    I'm confused by this exception
    java.lang.IllegalStateException: Nesting scrollable in the same direction layouts like LazyColumn and Column(Modifier.verticalScroll()) is not allowed.
    when the compose docs clearly state
    Automatic nested scrolling: Simple nested scrolling requires no action on your part. Gestures that initiate a scrolling action are propagated from children to parents automatically, such that when the child can't scroll any further, the gesture is handled by its parent element
    The docs then go on to give a sample of nesting one vertical scrolling box inside another vertically scrolling box.
    i
    • 2
    • 4
  • t

    Tolriq

    10/21/2021, 3:19 PM
    Is it normal that
    NestedScrollConnection
    is not called at all when `listState.scrollToItem`is called manually?
    a
    s
    • 3
    • 6
  • t

    theapache64

    10/21/2021, 4:22 PM
    Animation: What is
    FloatTweenSpec
    ? and how is it different from
    tween
    ? 🤔
    d
    • 2
    • 2
  • s

    saket

    10/21/2021, 4:38 PM
    I have a
    LazyColumn
    with
    AndroidView
    items and I’m just noticing that
    AndroidView#update
    is getting called on every scroll/recomposition. Is this expected?
    ➕ 1
    t
    a
    • 3
    • 11
  • c

    colintheshots

    10/21/2021, 4:55 PM
    Is it possible to call a parent's onClick method or Clickable modifier inside of a ClickableText's onClick method? I want clicks to bubble up if the user did not press a link.
    • 1
    • 1
  • m

    Michael Langford

    10/21/2021, 4:56 PM
    I have a compose Button onClick handler that saves important information. It's too slow to just run it on the main thread. GlobalScope.launch{} pops out a warning about that API being delicate. I don't want the coroutine to be suspended and cancelled if the view is dismissed, so LaunchedEffect seems to be the wrong approach. Where is the appropriate place to situate the coroutine scope?
    c
    t
    c
    • 4
    • 5
  • t

    theapache64

    10/21/2021, 5:17 PM
    but i don’t see
    animateBoundsAsState
    ? 🤔 removed or its doc mistake?
    t
    d
    • 3
    • 2
  • t

    Tolriq

    10/21/2021, 6:07 PM
    I have random rare crash that makes no sense at all that seems to be generated from
    Modifier.weight(1f, fill = false)
    Error:
    java.lang.ClassCastException: java.lang.Float cannot be cast to java.lang.Boolean
            at xxxxx.library.LiveLiterals$LibraryDestinationKt.Boolean$arg-1$call-weight$val-tmp3_modifier$fun-$anonymous$$arg-3$call-Row$fun-$anonymous$$arg-1$call-CompositionLocalProvider$fun-$anonymous$$arg-3$call-Column$fun-$anonymous$$arg-3$call-Row$fun-$anonymous$$arg-3$call-Box$fun-AlbumEntry(Unknown Source:31)
    Is there something I miss in the stack trace?
    a
    c
    c
    • 4
    • 10
  • a

    appmattus

    10/21/2021, 6:48 PM
    have started to play around with MotionLayout but getting a lot of jank when using it with LazyColumn so wondering whether what I'm doing wrong. Basically I'm creating a collapsible style header style, but have simplified the code down for the purposes here, so I have a box to represent the header with the rest of the screen taken up as a LazyColumn. With only a handful of items (simply
    Text
    ) in the list the animation becomes jerky. In comparison, having only the button in the list the animation is relatively smooth. (Videos attached) (Code and videos in thread)
    :thread-please: 1
    • 1
    • 4
  • a

    AmrJyniat

    10/21/2021, 6:53 PM
    When I set
    isError = true
    to the TextField the border's color not becomes only Red but I see it's combination of PrimaryColor and Red, any tips about the issue?
    c
    a
    • 3
    • 4
  • a

    adjpd

    10/22/2021, 11:59 AM
    Are there plans to make a Jetpack Compose date/time picker? (You can use Android's views but these change from os version to os version etc. And the material library's date time picker uses fragments which is annoying)
    👀 4
    ➕ 5
    d
    m
    +2
    • 5
    • 5
  • k

    Kamesh Yadav

    10/22/2021, 12:40 PM
    Getting a crash after upgrading to compose 1.0.4
    java.lang.IllegalStateException: Snapshot is not open
    • 1
    • 3
Powered by Linen
Title
k

Kamesh Yadav

10/22/2021, 12:40 PM
Getting a crash after upgrading to compose 1.0.4
java.lang.IllegalStateException: Snapshot is not open
App is working fine with
1.0.3.
I am running the app in emulator if that helps.
java.lang.IllegalStateException: Snapshot is not open
        at androidx.compose.runtime.snapshots.SnapshotKt.validateOpen(Snapshot.kt:1459)
        at androidx.compose.runtime.snapshots.SnapshotKt.access$validateOpen(Snapshot.kt:1)
        at androidx.compose.runtime.snapshots.MutableSnapshot.apply(Snapshot.kt:585)
        at androidx.compose.runtime.Recomposer.applyAndCheck(Recomposer.kt:799)
        at androidx.compose.runtime.Recomposer.access$applyAndCheck(Recomposer.kt:103)
        at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1064)
        at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:103)
        at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:447)
        at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:416)
        at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34)
        at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
        at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
        at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:856)
        at android.view.Choreographer.doCallbacks(Choreographer.java:670)
        at android.view.Choreographer.doFrame(Choreographer.java:603)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
The crash is only happening in android 6 emulator, I do not have physical device with android 6.
View count: 3