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

    Colton Idle

    08/25/2021, 8:02 PM
    Top app bar with a background color shows as expected, but if I set it to transparent then I get this inset/shadowed look. Am I misusing TopAppBar in some way? I just want to be able to show the content underneath it 😅
    TopAppBar(
        backgroundColor = Color.Red //Works as expected
        backgroundColor = Color.Transparent //Doesn't work as expected
    n
    c
    +3
    • 6
    • 15
  • z

    Zach Klippenstein (he/him) [MOD]

    08/25/2021, 8:29 PM
    How is Jetpack Navigation’s Compose support handling `AndroidView`s nested inside composable destinations? I see that
    NavBackStackEntryProvider
    sets all the owner locals for the destination (
    ViewModelStore
    ,
    Lifecycle
    ,
    SavedStateRegistry
    , and
    SaveableStateRegistry
    ), and that
    AndroidView
    manages its view’s hierarchy state, but if a view underneath an
    AndroidView
    inside a composable destination asks for the
    ViewTreeSavedStateRegistryOwner
    , for example (and same for the other 2 view tree owners), wouldn’t they skip past the compose nav destination’s owners and find the owner on the android view containing the composition with the nav host? I would expect
    AndroidView
    to set the view tree owners from the respective composition locals on its child view.
    ➕ 2
    i
    • 2
    • 19
  • a

    adjpd

    08/25/2021, 10:38 PM
    If I do something like the below, am I right in thinking I cannot use preview it, because `ViewModel`s aren't supported in
    @Preview
    ?
    @Composable
    private fun TodoActivityScreen(todoViewModel: TodoViewModel) {
      ...
    }
    i
    • 2
    • 15
  • s

    Skolson5903

    08/25/2021, 11:21 PM
    Is anyone having build issues with a compose app using the new 1.5.30 kotlin release? I have an app that builds and debugs fine using 1.5.21. Today I tried to upgrade the kotlin version in the gradle build to 1.5.30. Sync worked fine, but a build of the app fails in the compileDebugKotlin build task with the call stack below. (I went back to 1.5.21 and am working again.) Anyone else seen something like this (moved call stack to thread)?
    t
    k
    • 3
    • 8
  • s

    Slackbot

    08/25/2021, 11:21 PM
    This message was deleted.
    🙅 3
    :thread-please: 14
    d
    s
    • 3
    • 2
  • r

    Rafiul Islam

    08/26/2021, 5:33 AM
    If I navigate from Screen A to Screen B using popUpTo(A){ inclusive = true }. Shouldn't my Screen B act like a start destination. I mean I want to exit my app if I press system back button from screen B. But in my case it is not happening if I press the back button from Screen B, it does nothing.
    ➕ 1
    w
    • 2
    • 1
  • a

    Alex

    08/26/2021, 7:26 AM
    Does anyone know the state of LazyColumn item change animations (RecyclerView diffing animations) in compose?
    j
    • 2
    • 2
  • n

    Napa Ram

    08/26/2021, 7:28 AM
    HI Everyone does anyone know how can i remove internal padding of textfield for leading and trailing icon
    👀 1
    f
    a
    +2
    • 5
    • 7
  • n

    Nathan Castlehow

    08/26/2021, 8:29 AM
    Hey hey, Testing question if anyone has a quick sec -> “Compose tests are synchronized by default with your UI. When you call an assertion or an action via the
    ComposeTestRule
    , the test will be synchronized beforehand, waiting until the UI tree is idle” Does this synchronisation on assertions include custom idling resources which have been registered? Or would I have to call waitForIdle() in between each line that makes async changes (eg. a network call)?
    • 1
    • 1
  • t

    Tin Tran

    08/26/2021, 9:31 AM
    Hi! I have this weird bug with text field on 1.1.0-alpha02 Does anyone know how to fix it?
    Screen_Recording_20210826-163028_GOLFTEC Clubhouse 3.mp4
    👀 3
    a
    • 2
    • 2
  • p

    Piotr Prus

    08/26/2021, 11:55 AM
    I just published Display Map Snapshot using Jetpack Compose https://link.medium.com/AEqkE3Af2ib I am still concerned about using DisposableEffect for the job, but it works 🙂 . Any feedback is welcome. Side question: Is it fine to put it here or I should use #feed? It is all about compose so I thought this channel is a good place 😉
    ➕ 1
    🎉 3
    z
    • 2
    • 1
  • d

    dimsuz

    08/26/2021, 12:12 PM
    If I have a
    Box
    with two composables of different height and use `AnimateVisibility`/`AnimateContent` so that one of them is removed, what is the best way to make this
    Box
    stay with
    height = max(composable1.height, composable2.height)
    ? Otherwise layout content jumps which doesn't look good.
    ➕ 2
    d
    • 2
    • 3
  • j

    Jonas Frid

    08/26/2021, 1:09 PM
    I have a TextField, but I’d like the label to be left aligned with the underline. Anyone that knows how I can to this seemingly simple task?
    c
    • 2
    • 2
  • r

    rkeazor

    08/26/2021, 1:25 PM
    For those that use Compose in production, can I hear your story? where there any performance hits or perhaps improvements you experience , while having compose is prod?
    c
    a
    +2
    • 5
    • 6
  • c

    Colton Idle

    08/26/2021, 1:54 PM
    Trying to recreate this. Having 2 issues: 1. I don't know how to get the permanent bottomSheet to have a set weight/percentage based height. 2. My rounded corners on the bottom sheet end up white. Code and current screenshot in thread.
    a
    v
    h
    • 4
    • 12
  • a

    Alex

    08/26/2021, 1:59 PM
    Is there a way to make the cursor jump to the next TextField on (hardware keyboard) tab-press? Is there some way to enable this?
    h
    d
    r
    • 4
    • 9
  • m

    marios proto

    08/26/2021, 2:49 PM
    👋 Rookie question! I am trying to align the icon with the text so that they are on the same height. This is the code for reproducing it
    @Composable
    fun IconTopLeftText(
        backgroundImageId: Int,
        iconId: Int,
        padding: Int = 16,
        imagePadding: Int,
        text: String,
        textColor: Int,
        textSize: Int
    ) {
        Box(modifier = Modifier
            .padding(padding.dp)
            .semantics(true) { }) {
            val drawable = AppCompatResources.getDrawable(LocalContext.current, backgroundImageId)
    
            Image(
                rememberDrawablePainter( drawable ),
                contentDescription = null)
            Row(
                horizontalArrangement = Arrangement.Start,
                verticalAlignment = <http://Alignment.Top|Alignment.Top>,
            ) {
                Image(
                    painter = painterResource(id = iconId),
                    modifier = Modifier
                        .padding(end = imagePadding.dp),
                    contentDescription = null
                )
    
                Text(
                    text = text,
                    fontSize = textSize.sp,
                    color = colorResource(id = textColor)
                )
            }
        }
    }
    Any ideas what am I missing please?
    ➕ 1
    d
    d
    +2
    • 5
    • 10
  • n

    Nick

    08/26/2021, 3:48 PM
    Something that made life easy with the XML was to keep all the properties in the same order. Is there a way to keep all the parameters in the same order for a composable element/function?
    r
    c
    f
    • 4
    • 12
  • r

    rajesh

    08/26/2021, 4:33 PM
    I've one variable (paging data stream) that gets data from view model based on some input id. This data should only arrived when user click on certain button, else data would be empty. How can i make sure that this data comes from view model when user click on button and provide that input id. code is in thread
    a
    • 2
    • 5
  • a

    adjpd

    08/26/2021, 4:42 PM
    How does Jetpack Compose work with the Android system's dark mode toggle? As I understand, dark mode is enabled with a boolean passed into the generated
    MyAppNameTheme
    . But that boolean doesn't seem dependent on the Android system's dark mode. Am I missing something?
    c
    c
    • 3
    • 21
  • t

    Tolriq

    08/26/2021, 4:56 PM
    What is the proper way to have a bottomsheet shown over the navigation bar from a subscreen ?
    ➕ 1
    c
    • 2
    • 2
  • c

    Chris Johnson

    08/26/2021, 5:25 PM
    Is there a way of manually calling/forcing the onClick of a composable? My use case is I have a RadioButton inside a row and I want the radioButton's indication to happen when the Row is selected. Something similar to the old
    View.performClick
    p
    h
    +2
    • 5
    • 22
  • m

    Mohamed Ibrahim

    08/26/2021, 5:32 PM
    So I wondering if there’s an extension function that do the following,
    if (condition){
      wrapComposableWith( Container() )
    } else {
      createComposable
    }
    z
    • 2
    • 3
  • r

    Rafiul Islam

    08/26/2021, 7:34 PM
    How can I make out of many only two or more specific composable screens in the Navigation graph share the same ViewModel?
    i
    • 2
    • 7
  • s

    Shivam Kumar Jha

    08/26/2021, 7:37 PM
    Has anyone faced error when passing a string URL via compose navigation with args? If I pass a short string, error does not happen https://gist.github.com/ShivamKumarJha/fcc571e55200e0cf8dd4ec5fdfd2625f
    f
    i
    • 3
    • 7
  • a

    Anthony

    08/26/2021, 7:49 PM
    In compose api guidelines, what does
    App development SHOULD prefer simpler concrete types until the abstraction provided by an interface proves necessary. When it does, adding a factory function for a default implementation as outlined above is a source-compatible change that does not require refactoring of usage sites.
    mean exactly? Should we not hoist our state with an interface and an implementation like so?
    a
    • 2
    • 3
  • m

    mcpiroman

    08/26/2021, 7:54 PM
    Meta - I see a lot of questions strictly regarding navigation in compose and (I don't use it but) it seems like it is a quite separate library with its own reasoning, not so related to the core compose. Just if - wouldn't it be reasonable to create separate compose-navigation channel?
    d
    s
    • 3
    • 2
  • d

    dimsuz

    08/26/2021, 9:11 PM
    Is there somewhere a Discourse-based site for Compose? Can't help but feel like Slack is not very good medium to drive discussions/questions/communication. It's heavy, searching is not very good, many discussions get lost inside isolated threads (I get notified only of ones I'm participating in, can't see if new posts arrive in some threads which may be relevant to me). So I thought maybe someone did set up something Discourse-like or maybe plans to?
    ➕ 2
    c
    • 2
    • 2
  • s

    Stylianos Gakis

    08/26/2021, 9:56 PM
    A question about animations. I have a FAB that I would like to animate in using
    AnimatedVisibility
    inside a box, so no row or column scope. It works alright but the clipping of how the animation opens up is a square. Meaning that it looks awkward as it comes into the screen especially since the shadows are looking weird. Is there a way to provide a clipping of how it should be expanded just like how I am passing that it should be expanding from the center?
    d
    j
    • 3
    • 10
  • j

    jkm

    08/27/2021, 2:01 AM
    Hey everyone, quick question regarding state in compose. Say I have a screen full of checkboxes, and I receive a model that details whether or not they should be toggled. i.e.
    data class Model( var one: Boolean, var two: Boolean, //etc)
    do I: A. declare each of the checkboxes states ? i.e.
    var someState by remember { mutableStateOf(myModel.one) }
    B. declare the state of the collection of checkboxes as
    var someState by remember { mutableStateOf(myModel) }
    I would like to do B, but I’m struggling with the state change callbacks, I’m thinking I might have to do A
    ➕ 1
    w
    • 2
    • 2
Powered by Linen
Title
j

jkm

08/27/2021, 2:01 AM
Hey everyone, quick question regarding state in compose. Say I have a screen full of checkboxes, and I receive a model that details whether or not they should be toggled. i.e.
data class Model( var one: Boolean, var two: Boolean, //etc)
do I: A. declare each of the checkboxes states ? i.e.
var someState by remember { mutableStateOf(myModel.one) }
B. declare the state of the collection of checkboxes as
var someState by remember { mutableStateOf(myModel) }
I would like to do B, but I’m struggling with the state change callbacks, I’m thinking I might have to do A
➕ 1
w

Will Shelor

08/27/2021, 2:30 AM
I think if you want to use the second, you would need to say someState = someState.copy(two = true), or something like that. I believe x by remember will redraw only when the object is directly assigned, not when the states within it are updated.
j

jkm

08/27/2021, 2:42 AM
Thanks! You’re correct, didn’t realise a change to
State<T>.someProperty
wouldn’t trigger a recomposition
View count: 1