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

    caelum19

    08/02/2020, 10:41 AM
    Hi, when I have two instances of a composable with FilledTextField, I'm getting this error:
    java.lang.IllegalArgumentException: Key -1277534736 was already registered. Please call unregister before registering again
            at androidx.ui.savedinstancestate.UiSavedStateRegistryImpl.registerProvider(UiSavedStateRegistry.kt:96)
            at androidx.ui.savedinstancestate.ValueProvider.updateAndReturnValue(RememberSavedInstanceState.kt:103)
            at androidx.ui.savedinstancestate.RememberSavedInstanceStateKt.rememberSavedInstanceState(RememberSavedInstanceState.kt:68)
    Any thoughts? Thanks 🙂
    a
    7 replies · 2 participants
  • a

    Archie

    08/02/2020, 12:45 PM
    Is there a way to add Snapping behavior for
    Horizontal Scroller
    just like how
    ViewPager
    snaps per page?
    h
    z
    +1
    6 replies · 4 participants
  • s

    Sinan Kozak

    08/02/2020, 3:17 PM
    Hi, is it possible to create shared element transition between one compose to a new compose function that replace previous one? Also i struggle to keep my head around how to animate a view from minimum width to fillMaxSize. Is that kind of animation possible with dev15?
    z
    3 replies · 2 participants
  • b

    bohregard

    08/02/2020, 5:03 PM
    Ok y’all, how do you draw a view that has no children but has a color background?
    Surface(
        color = Color(0xFFFF0000),
        modifier = Modifier.width(5.dp).fillMaxHeight()
    ) {
        Text("")
    }
    I’ve got this, but if I remove the Text item the color isn’t drawn which is really all I care about
    a
    f
    13 replies · 3 participants
  • g

    galex

    08/03/2020, 7:00 AM
    Does it makes sense to pass a
    mutableStateOf<User>
    to the children as parameter so some
    Composables
    in the hierarchy can update that state so that all the hierarchy will be recomposed? In this case, I have a screen/composable that will sign-in the user, and when the user is signed in I’d like to update the rest of the hierarchy that it happened. The goal is to show all my screens if a user signed-in or not (I’m using
    compose-router
    for the backstack)
    j
    f
    +1
    25 replies · 4 participants
  • b

    brandonmcansh

    08/03/2020, 1:14 PM
    Is there a modifier im missing to get the snackbar to align to the bottom?
    m
    f
    9 replies · 3 participants
  • r

    Ricardo C.

    08/03/2020, 6:07 PM
    Is there any example project that combines backstack + keeping screen state + dependency injection via params? ie, a regular app we're used to. more than the simple examples
    j
    z
    +4
    17 replies · 7 participants
  • g

    Griffin.Park

    08/04/2020, 3:30 AM
    Is there an example of a working TextField composable for something like username and password input using a standard keyboard? I'm not sure how to limit entry to one line either
    v
    2 replies · 2 participants
  • c

    Colton Idle

    08/04/2020, 5:01 AM
    My team uses Android Studio 4.0.1 and we don't use compose. We're building a new set of components in the current android ui toolkit, but we're interested in building composables at the same time. Is there a chance that we can build the composables in the same project or do we have to force everyone to use 4.2.0 canary (updating agp, etc). I'd really like to continue opening the project with AS stable to build/dev/deploy, but if I open in AS canary I can see the library of composables we're building out. Is that possible or just asking for trouble? The simpler thing to do would just to have a separate repo, but I'd like to stay away from that if possible as I would prefer to have old/new components in the same repo.
    i
    t
    2 replies · 3 participants
  • g

    galex

    08/04/2020, 7:19 AM
    Should we not be able to call
    launchInComposition() {}
    inside a
    @Composable
    extension function? The extension function looks like the following:
    @Composable
    fun <I, O> ActivityResultRegistry.activityResultLauncher(): : ActivityResultLauncher<I> {}
    But inside of it inside another
    Composable
    , I am unable to call
    launchInComposition
    (see screenshot).
    f
    3 replies · 2 participants
  • p

    Philip Blandford

    08/04/2020, 10:21 AM
    I found that if I don't include a ComponentActivity in my AndroidManifest, then using createComposeRule() means that test stalls and eventually bombs out with "activity never becomes requested state "[destroyed, resumed, created, started]" I wonder would it be better to have a more explicit exception message here, as it took me quite a while to figure out what I'd done wrong? Something like "ComponentActivity not found - have you included it in your AndroidManifest?".
    f
    1 reply · 2 participants
  • b

    brandonmcansh

    08/04/2020, 12:42 PM
    Working with LazyColumnItems with a flowable provided backing list I'm hitting a weird UI state where triggering a delete() of
    test9
    causes
    test8
    to also be removed visually but remain in the list at the repository level as well as the list that the UI is fed. The
    test8
    gets added back on "undo" and
    test9
    gets returned on scroll
    Screen Recording 2020-08-04 at 8.37.30 AM.mov
    m
    6 replies · 2 participants
  • z

    zak.taccardi

    08/04/2020, 5:54 PM
    My understanding is that
    @Compose
    does not support backstack handling automatically, like
    FragmentManager
    does, and that we would be forced to track backstack behavior ourselves in business logic (which makes more sense, as it’s just so flexible). Assuming I’m correct about this, is there any documentation or information anywhere that advocates managing backstack logic ourselves in a
    @Compose
    world? Like representing a backstack like
    listOf(screen1, screen2)
    ? I’m looking to share this info with colleagues rather than argue for it myself haha
    p
    i
    +2
    5 replies · 5 participants
  • h

    huannguyen

    08/05/2020, 7:42 AM
    I believe existing UI libraries (e.g., custom
    RecyclerView
    ) would not work with a
    Composable
    function. Anyone knows if there is any guide at this stage to convert such libraries to
    Compose
    ?
    👀 1
    j
    a
    +1
    7 replies · 4 participants
  • m

    MBegemot

    08/05/2020, 11:02 AM
    @Composable
    fun startScreen() {
       FlowComponent(sflow = myfirstFlow())
    }
    
    @Composable
    fun FlowComponent(sflow: Flow<String>){
           val cnt:String by sflow.collectAsState("")
           val sl =state { mutableListOf<String>()}
           sl.value.add(cnt)
           Box(Modifier.preferredHeight(150.dp)){
              sl.value.forEach {
                Text(it)
            }
        }
    }
    
    fun myfirstFlow()=flow<String>{
        val t=110L
       emit("task 1 succeded")
        delay(t)
       emit("task 2 failed")
        delay(t)
        emit("task 3 succeded")
        delay(t)
        emit("task 4 failed")
        delay(t)
        //emit("uuu"+getNewsPapers(null))
    This is a startup screen as I run several functions I intend to emit a string to the flow component that will add it to a list of stings and then write them on screen. And it works but only if I add a certain delay between emits, if the delay is to small or null then I only get the first and last emit. I I'm wrong if i believe that this should work without any delay at all?
    z
    c
    11 replies · 3 participants
  • t

    tcracknell

    08/05/2020, 5:35 PM
    Hello! The latest Jetpack Compose minor release, dev16, has just been released! You can get it now on Google’s Maven Repository. Release notes are available at https://developer.android.com/jetpack/androidx/releases/compose and https://developer.android.com/jetpack/androidx/releases/ui. Please note that the major refactoring continued and the updated mapping can be found here: https://developer.android.com/jetpack/androidx/releases/compose#package-refactor. As always, feedback is welcome; please log issues at https://issuetracker.google.com/issues/new?component=612128!
    🎉 14
    🔥 1
    😍 24
    🙏🏼 5
    z
    j
    +5
    10 replies · 8 participants
  • r

    romainguy

    08/05/2020, 6:00 PM
    https://github.com/romainguy/sample-materials-shop is updated to work with dev16 if you need an example of the new imports to use and what compiler version to use
    🎉 15
    a
    5 replies · 2 participants
  • a

    amar_1995

    08/06/2020, 12:12 AM
    Is there any thing similar to DataTable which I believe was in dev08 ?
    a
    2 replies · 2 participants
  • z

    Zach Klippenstein (he/him) [MOD]

    08/06/2020, 1:07 AM
    I’m getting an error in previews with dev16 and AS 4.2 canary 7. Is it worth filing a bug?
    Untitled
    b
    3 replies · 2 participants
  • b

    bohregard

    08/06/2020, 4:21 AM
    I’m getting an error trying to build:
    Caused by: java.lang.IllegalStateException: Couldn't obtain compiled function body for public final inline fun <get-current>(): T defined in androidx.compose.runtime.Ambient[PropertyGetterDescriptorImpl@6d6b1e59]
    a
    2 replies · 2 participants
  • m

    Mehdi Haghgoo

    08/06/2020, 5:05 AM
    I have noticed some composables have a content field, and they also have a body for content. Should the children composables go in their content field or written in their body? For example surface:
    @Composable
    fun Surface(
        modifier: Modifier = Modifier,
        shape: Shape = RectangleShape,
        color: Color = MaterialTheme.colors.surface,
        contentColor: Color = contentColorFor(color),
        border: Border? = null,
        elevation: Dp = 0.dp,
        content: @Composable () -> Unit
    )
    a
    r
    +2
    7 replies · 5 participants
  • m

    Mehdi Haghgoo

    08/06/2020, 5:21 AM
    Another question, how to refer to the current composable in a Modifier? For example, trying to change the text value of a Text modifier using a clickable modifier.
    Text(text = "Hello Android!", modifier = Modifier.clickable(onClick =  /*Code to change the text Hello Android */))
    a
    j
    2 replies · 3 participants
  • a

    Adrian Blanco

    08/06/2020, 10:37 AM
    I've been having some problems with font weights for a while now. It seems like having multiple fonts with different weights in a fontFamily just picks the font with the closest weight and ignores the others. On dev-16 and core-ktx 1.5.0-alpha01 now, and it stopped working properly somewhere around dev-12 or 13.
    1 reply · 1 participant
  • k

    Klaas Kabini

    08/06/2020, 12:00 PM
    Updated to dev16 today and I cannot do this anymore. Why is mutableStateOf not allowing property delagates anymore? Am i missing something?
    class Position(x: Int, y: Int) {
        var x by mutableStateOf(x)
        var y by mutableStateOf(y)
    }
    g
    r
    +1
    9 replies · 4 participants
  • t

    tjohnn

    08/06/2020, 1:14 PM
    I can't seem to be able to update dev15 and dev16, I have these repositories in place:
    maven(url =  "<https://dl.bintray.com/kotlin/kotlin-eap/>")
    jcenter()
    google()
    d
    k
    4 replies · 3 participants
  • d

    dam5s

    08/06/2020, 1:15 PM
    Some packages were renamed, maybe check that?
    t
    1 reply · 2 participants
  • n

    Neal Sanche

    08/06/2020, 3:04 PM
    I have a small compose example app that I've been updating as the dev releases are made, and dev15 and dev16 have been challenging. Specifically, I'm finding on dev16 with Android Studio 4.2 Canary 7, I can no longer see any previews. The preview window just keeps telling me to compile the app. The app was based off the Empty Compose Activity example initially, and the code compiles. Would be happy to drop the code somewhere if people want it.
    ➕ 2
    e
    d
    +2
    6 replies · 5 participants
  • d

    Dominaezzz

    08/06/2020, 3:45 PM
    Can compose be used on arbitrary trees now?
    s
    c
    16 replies · 3 participants
  • z

    Zach Klippenstein (he/him) [MOD]

    08/06/2020, 9:23 PM
    I work on an app that has a feature in debug builds where we dump the entire view hierarchy of the main window in certain cases, e.g. for crash reports or manually via a special debug menu. This can be really helpful for figuring out the state of the UI when things go wrong. Is it possible to do this with Compose? What would that look like? One option would be to walk the semantics tree, although I’m not sure that would contain enough information for debugging the UI itself. Another option would be getting access to the root
    LayoutNode
    and walking the node tree, but many Composables just wrap other Composables and don’t have their own `LayoutNode`s, modifiers are often contributed from multiple composables for a single node, etc, so that’s not ideal either. I’ve seen some work being done for Android Studio tooling around extracting some data about stuff like this by inspecting the slot table directly. Would it be reasonable to request a public API for exposing that parsing in debug builds?
    💯 14
    v
    a
    +1
    12 replies · 4 participants
  • p

    Patrick Yin

    08/06/2020, 9:50 PM
    One question about wrapping the classic android view inside of a compose component: See code below, if you click TextView area, it’s not clickable, but if you click the Box’s padding area, it’s clickable. And if replace
    emitView(::TextView)
    with a compose
    Text("")
    , it works well. Is it an intentional behavior? Or there is something wrong?
    @Composable
    fun MarketLabel(text: String) {
    //  Android classic view
      emitView(::TextView) {
        it.text = text
      }
    }
    
    @Composable
    fun SomeThing() {
      Box(
        modifier = Modifier
          .clickable(
            onClick = {
              doingSomething()
            }
          )
          .padding(16.dp)
      ) {
        MarketLabel("Test")
      }
    }
    r
    2 replies · 2 participants
Powered by Linen
Title
p

Patrick Yin

08/06/2020, 9:50 PM
One question about wrapping the classic android view inside of a compose component: See code below, if you click TextView area, it’s not clickable, but if you click the Box’s padding area, it’s clickable. And if replace
emitView(::TextView)
with a compose
Text("")
, it works well. Is it an intentional behavior? Or there is something wrong?
@Composable
fun MarketLabel(text: String) {
//  Android classic view
  emitView(::TextView) {
    it.text = text
  }
}

@Composable
fun SomeThing() {
  Box(
    modifier = Modifier
      .clickable(
        onClick = {
          doingSomething()
        }
      )
      .padding(16.dp)
  ) {
    MarketLabel("Test")
  }
}
r

romainguy

08/06/2020, 9:54 PM
The team has been making fixing in the input handling across boundaries. Looks like not all fixes made it to dev16.
p

Patrick Yin

08/06/2020, 10:11 PM
Ah, nice call. I’m on dev15. It works on dev16. thanks @romainguy
View count: 1