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

    Nat Strangerweather

    04/04/2022, 3:53 PM
    [UPDATED WITH SOME CODE] What happens when I exit and restart my app that means my function to update my Boolean in my room database finally works? I am trying to work out what I am missing that happens at onCreate time but does not happen otherwise. I use this code in a onClick function... 🧵
    l
    • 2
    • 7
  • d

    dimsuz

    04/04/2022, 4:06 PM
    I have a custom layout where I have something like
    MyLayout(slot = { visible -> AnimatedVisibility(visible) { ... } })
    and the logic is such that I want that
    visible
    to be calculated based on available height and slot size: I measure my "slot" then if it fits, I pass visibility =
    true
    , otherwise
    false
    . I wanted to use
    SubcomposeLayout
    for this but turns out that to calculate
    visible
    I need to
    subcompose/measure
    that slot and to
    subcompose/measure
    it I need to calculate
    visible
    🐔 🥚 Is this possible? Inner State + recompose?
    a
    • 2
    • 8
  • l

    Luke

    04/04/2022, 6:24 PM
    During UI tests, is there a way to make assertions about the background color of a node? Quick Google search tends to point towards the negative but maybe someone in here has found a solution?
    j
    • 2
    • 2
  • z

    Zoltan Demant

    04/05/2022, 4:08 AM
    After upgrading to the latest compose release (1.2.0-alpha06) the keyboard shows up everytime the app is put back into the foreground if youve "manually" brought it up previously. Just wanting to check if anyone else is able to recreate this before I post a bug report about it?
    ➕ 1
    f
    t
    s
    • 4
    • 19
  • a

    Android75

    04/05/2022, 4:11 AM
    I don’ understand how can use navController and change scree/pager. I have 3 screen @Ian Lake can you help me. I need to change page and page is decide by viewModel ``````
    i
    i
    g
    • 4
    • 16
  • t

    Tgo1014

    04/05/2022, 9:34 AM
    Is there a way to control the “offset” of a
    LazyRow
    ? The idea would be to manually controle the
    LazyRow
    position to sync the scroll when dragging a pager
    a
    • 2
    • 13
  • k

    krzysztof

    04/05/2022, 11:33 AM
    Does anyone know how to successfully suppress compose compiler warning for Kotlin version? I’m trying to run a project with KT 1.6.20, compose 1.1.1. I’ve added compiler options:
    kotlinOptions {
        freeCompilerArgs = listOf("-P", "plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true")
      }
    But then I get this error
    java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl org.jetbrains.kotlin.ir.builders.ExpressionHelpersKt.irSetField(org.jetbrains.kotlin.ir.builders.IrBuilderWithScope, org.jetbrains.kotlin.ir.expressions.IrExpression, org.jetbrains.kotlin.ir.declarations.IrField, org.jetbrains.kotlin.ir.expressions.IrExpression)'
    From Kotlin compiler
    🇳🇴 1
    📵 1
    f
    • 2
    • 4
  • j

    josefdolezal

    04/05/2022, 12:13 PM
    Hey folks! I would use second pair of eyes 👀. I am working on a “rich text view” which would allow me to render additional content (images, for simplicity) along standard text. I use Compose’s
    Text
    with annotated string and embed images using
    inlineContent
    . What I am unable to do is to correctly align embedded content on text’s base line. Details in 🧵
    😯 1
    i
    • 2
    • 6
  • d

    Dejan Dobnikar

    04/05/2022, 12:23 PM
    Hi, is there a way to pause/resume Compose animations? Something similar to
    Animator.pause()
    /`Animator.resume()` , which would work with all animation types (animate*asState/Animatable/updateTransition)? In the API reference I haven’t found anything related. For example I would like to pause/resume long-running animation on button click and also pause animation if activity is paused. One idea that I had is to have custom
    AnimationSpec
    and override
    vectorize
    fun which would return
    VectorizedAnimationSpec
    which would handle pause, but that does not sound like the best way to do it.
    m
    • 2
    • 1
  • a

    Aaron Waller

    04/05/2022, 2:09 PM
    Anyone knows how I can arrange the two inner BottomNav Items so that they are not so close to the “+” FAB? I tried surrounding the forEach which displays the Items with a Row and use the Arrangement modifier like so:
    Row(horizontalArrangement = Arrangement.SpaceBetween) { //Not working :(
    items.forEach { item ->
        BottomNavigationItem(
            icon = { Icon(painterResource(id = item.icon), contentDescription = item.title) },
            label = { Text(text = item.title) },
            selectedContentColor = Color.White,
            unselectedContentColor = Color.White.copy(0.4f),
            alwaysShowLabel = true,
            selected = currentRoute == item.route,
            onClick = {
                navController.navigate(item.route) { 
                    navController.graph.startDestinationRoute?.let { route ->
                        popUpTo(route) {
                            saveState = true
                        }
                    } 
                    launchSingleTop = true 
                    restoreState = true
                }
            }
        )
    }
    
    }
    😯 1
    m
    a
    • 3
    • 12
  • r

    Romão

    04/05/2022, 3:15 PM
    How can I parse a local JSON file from assets folder into a LazyColumn (from list of data class)?
    k
    • 2
    • 2
  • c

    Colton Idle

    04/05/2022, 5:42 PM
    In my compose app in prod I started seeing this stacktrace and it only occurs on a single device. Anyone have anything similar happen to them?
    Fatal Exception: java.lang.IllegalArgumentException end cannot negative. [end: -1]
    androidx.compose.ui.text.TextRangeKt.packWithCheck (TextRange.kt:124)
    androidx.compose.ui.text.TextRangeKt.TextRange (TextRange.kt:37)
    androidx.compose.ui.text.input.EditingBuffer.delete$ui_text_release (EditingBuffer.kt:205)
    androidx.compose.ui.text.input.DeleteSurroundingTextCommand.applyTo (EditCommand.kt:271)
    androidx.compose.ui.text.input.EditProcessor.apply (EditProcessor.kt:110)
    🤔 3
    • 1
    • 1
  • k

    Kivia Brito

    04/05/2022, 6:09 PM
    Does anyone here with the UI test experience knows how can I test if a button is enable or disabled? I tried settings the
    Modifier.
    .clickable(enable = true) 
    .focusable(enable = true)
    And using the method
    fun SemanticsNodeInteraction.assertIsNotEnabled(): SemanticsNodeInteraction = assert(isNotEnabled())
    but my
    SemanticsConfiguration
    doesn't seems to contain the
    SemanticsProperties.Disabled
    key. Any thoughts in how to include this key to my
    SemanticsConfiguration
    ?
    f
    r
    • 3
    • 4
  • c

    Chris Fillmore

    04/05/2022, 8:14 PM
    I’m following directions on https://developer.android.com/reference/kotlin/androidx/core/splashscreen/SplashScreen to implement splash screen on Android <12. My app UI is otherwise built entirely in Compose. Is
    postSplashScreenTheme
    still important in this case? I don’t have a theme to reference here.
    a
    • 2
    • 2
  • r

    romainguy

    04/05/2022, 9:49 PM
    @enighma What do you need? Dithering should be automatically applied where necessary
    :thread-please: 1
    e
    • 2
    • 7
  • n

    natario1

    04/06/2022, 12:20 AM
    Is there a way for a composable ‘touch area’ to extend outside of the layout area? A hacky way maybe?
    e
    a
    • 3
    • 7
  • i

    Icyrockton

    04/06/2022, 7:58 AM
    is there a way to achieve rounded corners in the opposite direction?
    c
    • 2
    • 1
  • s

    Slackbot

    04/06/2022, 8:58 AM
    This message was deleted.
    n
    t
    • 3
    • 3
  • b

    Bino

    04/06/2022, 11:46 AM
    How can
    backgroundTint
    be translated to compose buttons?
    c
    • 2
    • 5
  • l

    Lasse Magnussen

    04/06/2022, 1:53 PM
    Hi people! I was thinking let’s rehash the compose navigation + parcelable discussions. What does the future look like? Will the be a, decent, official solution for this? I get that someone is advocating single source of truth etc, but IMO there are mitigating circumstances when migrating code and also when doing larger reusable components. Gradle modules also cause friction with the single-source-of-truth idea. I just don’t get why compose needs to be overly opinionated about routes and NOT parcelables? (Excuse me if this has been recently discussed; I found two threads, 1 from august last year and 1 from october 2020) To put it plainly, I want to just serialise my parcelables, base64 encode them, and pass them through. At least until a viable official alternative is in place.
    i
    • 2
    • 27
  • j

    julioromano

    04/06/2022, 3:00 PM
    Does Compose have a method to compute contrast between 2 colors? Something similar to
    ColorUtils.calculateContrast()
    but I was looking for something not tied to the Android SDK.
    ✅ 1
    a
    • 2
    • 1
  • j

    julioromano

    04/06/2022, 3:01 PM
    How can I convert an sRGB color to YUV? There is no YUV in
    ColorSpaces
    .
    a
    • 2
    • 2
  • m

    Mehdi Haghgoo

    04/06/2022, 3:02 PM
    "ASking for measurement result of unmeasured layout modifier" Does anyone know how to solve this error?
    a
    • 2
    • 2
  • f

    frank

    04/06/2022, 4:37 PM
    I'm doing the tutoríal of codelabs: Codelabs tuto. In the tests I have seen that the scroll only scrolls until "lazy Columns" and can't reach extra column. What am I doing wrong?
    Column() {
            Surface(
                color = MaterialTheme.colors.primary
            ) {
                Text(
                    "Users:",
                    Modifier.fillMaxWidth(),
                    style = MaterialTheme.typography.h5.copy(fontWeight = FontWeight.ExtraBold),
                    textAlign = TextAlign.Center
                )
            }
    
            Divider()
    
            LazyColumn( // List names
                modifier = Modifier.padding(vertical = 4.dp)
            ) {
                items(names) { name ->
                    NamePickerItem(name)
                }
            }
    
            NamePickerName(name = "LuisEnrique2") // Extra item for compare
    }
    t
    • 2
    • 2
  • d

    dimsuz

    04/06/2022, 4:44 PM
    is there some kind of
    immutableStateOf(value)
    ? Usecase:
    val state = when (orientation) {
      Orientation.Landscape -> animateDpAsState(32.dp)
      Orientation.Portrait -> immutableStateOf(16.dp)
    }
    I could use
    mutableStateOf(16.dp)
    of course, just thought maybe something more lightweight exists.
    a
    • 2
    • 6
  • n

    nuhkoca

    04/06/2022, 4:55 PM
    Hello, how can I find the coordinate of a component inside root in pixels? I tried below but it is not working
    .onGloballyPositioned {
                        val rect = it.boundsInRoot()
                        onTitleEdgeMeasured(rect.top.roundToInt())
                    }
    • 1
    • 1
  • d

    dazza5000

    04/06/2022, 5:03 PM
    I think this has been asked before here: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1633949519417700, but I wanted to ask to see if there were any new discoveries. How is it possible to determine the max height needed for the items in a LazyRow so that you can set that as the height of each item so that the vertical height of the LazyRow doesn't change as you scroll?
    a
    c
    z
    • 4
    • 14
  • e

    enighma

    04/06/2022, 5:53 PM
    LazyLists + Dpad Out of the box it doesn’t scroll in new items. Is this something that I have to build my self, or easily enabled with modifiers?
    l
    • 2
    • 1
  • m

    Micko Cabacungan

    04/06/2022, 6:52 PM
    Is there a proper way to observe a SharedFlow in a Composable function, for StateFlow we'd use
    collectAsState
    but if I do that for a SharedFlow, it will remember the last value, instead of firing and forget
    c
    t
    • 3
    • 9
  • e

    eygraber

    04/06/2022, 9:26 PM
    If Kotlin 1.6.20 didn't land in this week's release, does that mean it's at least 2 weeks out?
    j
    j
    • 3
    • 5
Powered by Linen
Title
e

eygraber

04/06/2022, 9:26 PM
If Kotlin 1.6.20 didn't land in this week's release, does that mean it's at least 2 weeks out?
j

jw

04/06/2022, 9:27 PM
The CL hasn't even been merged yet
👍 1
if you're playing along at home http://r.android.com/2020776/
j

jim

04/07/2022, 9:38 PM
Yeah, should merge shortly, we got consensus on the last remaining issue today.
In the mean time, you can try the dev builds here: https://androidx.dev/storage/compose-compiler/repository
j

jw

04/08/2022, 12:16 AM
I appreciate all your effort that the monorepo of pain forces upon you
View count: 7