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

    Kazemihabib1996

    04/06/2020, 3:17 PM
    At the moment state (Model) is not retains on orientation change. Is this supposed to change in future or we are supposed to use ViewModel with jetpack compose?
    z
    l
    s
    • 4
    • 11
  • s

    Socheat KHAUV

    04/07/2020, 8:56 AM
    Hello is there a way to write a composable function for android.view.TextureView ?
    m
    • 2
    • 2
  • j

    Javier

    04/08/2020, 10:15 AM
    Is it possible to wrap/unwrap composables with Alt-Enter (same behaviour used in Flutter)?
    ➕ 1
    a
    c
    • 3
    • 11
  • s

    semoro

    04/08/2020, 12:02 PM
    I expirence some performance problems related to
    @Preview
    in Android Studio 4.1 Canary 4 There is some freezes on typing, which is caused by
    @Preview
    annotation discovery, I have thread dumps for it Also, there is some memory leak happens, as after few hours of work AS consumes 4-5 Gb of RAM, can provide heap analysis dump
    ➕ 5
    c
    k
    n
    • 4
    • 13
  • v

    Vinay Gaba

    04/08/2020, 4:25 PM
    I was trying to upgrade to dev08 and noticed some unexpected behavior when a Text composable is placed above a Card composable inside a Column. The text isn’t visible at all. My guess is that its something related to elevation/shadow.
    a
    v
    • 3
    • 4
  • v

    Vinay Gaba

    04/09/2020, 1:12 AM
    I found a old discussion from this channel around
    golden image testing facilities
    . I would love to know how you’ll are thinking about screenshot testing now? Moreover, what’s the long term vision for testing in Compose? Also, are there any testing frameworks/tools from the other declarative frameworks that you’ll are particularly excited about? It’s also possible this question was already covered before. In that case would be very grateful if someone could point me to that thread 🙏🏼
    j
    • 2
    • 4
  • s

    SrSouza

    04/09/2020, 2:40 AM
    Hi folks, I getting a unexpected behavior using Icon, the previous vector is being kept in the screen.
    m
    m
    +2
    • 5
    • 5
  • m

    molikto

    04/09/2020, 6:15 AM
    I have a question, how does a Composable function with a non-Unit return value works? Will the result of that function call be cached if the Composable function parameters doesn't change? I've found this pattern for Dialog works pretty well. It returns a MutableState so code outside can mutate it to show the dialog
    Untitled
    a
    • 2
    • 6
  • b

    Bacho Kurtanidze

    04/09/2020, 12:16 PM
    is it safe to use
    ContextAmbient.current
    wherever I want in my code?
    a
    t
    • 3
    • 4
  • n

    Nikit Bhandari

    04/09/2020, 7:12 PM
    drawImage(imageResource(R.drawable.baseline_menu_white_18dp)
            , Offset(midX, midY), Paint().apply { color = Color(25, 138, 128) })
    When I call the above
    drawImage
    method of Canvas, my build fails with the following error
    Functions which invoke @Composable functions must be marked with the @Composable annotation
    But Canvas already has the @Composable annotation, any clue what I might be missing here? Thanks
    l
    • 2
    • 1
  • z

    Zach Klippenstein (he/him) [MOD]

    04/10/2020, 4:38 PM
    Question about future direction: With so many things moving to modifiers (I believe yall intend to make the semantics stuff configurable via modifiers?), has there ever been any thought about making ambients configurable via modifiers? E.g.
    SomeComposable(modifier = Modifier.withAmbients(FooAmbient provides foo)) { … }
    a
    • 2
    • 4
  • c

    carbaj0

    04/10/2020, 6:52 PM
    is this the better way to change between light and dark mode?
    setContent {
                val (mode, setMode) = state { lightColorPalette() }
                MaterialTheme(mode) {
                    Button(onClick = { setMode(if (mode.isLight) darkColorPalette() else lightColorPalette()) }) {
                        Text(text = "button")
                    }
                }
            }
    l
    • 2
    • 1
  • z

    Zach Klippenstein (he/him) [MOD]

    04/11/2020, 12:34 AM
    I know yall are still rebasing onto the latest 1.3 compiler for the latest IR support, so is it safe to assume there won’t be any dev builds that support kotlin 1.4 anytime soon?
    a
    • 2
    • 12
  • s

    semoro

    04/11/2020, 4:22 AM
    I’m trying to implement list with animated swipe removal Do I really have to use
    stateFor
    and provide some key? https://gist.github.com/semoro/ea7c07cf3bcbd3bc4cbc4729b82b4140#file-composeremovalarea-kt-L64 Actually, if I don’t provide some kind of this id parameter, button click also hides subsequent list element, which is a bit counter-intuitive. Is it due to that changes of input parameters in RemovalArea’s child doesn’t cause recompose in RemovalArea itself, and previously occupied slot for deleted element became used by next one, without reset of state? Is there is some way to avoid passing
    id
    parameter?
    t
    z
    • 3
    • 22
  • a

    Adam Bennett

    04/11/2020, 9:11 AM
    Is there an equivalent to this in
    Canvas
    using Compose? I'm looking to do this
    override fun onDraw(canvas: Canvas?) {
            super.onDraw(canvas)
            calculatePropagation()
            canvas?.let { render() }
            postInvalidateDelayed(20)
        }
    But I can't seem to find an equivalent for repeatedly drawing to Canvas. I've done a tonne of digging through docs and on here - can anyone chime in?
    b
    t
    a
    • 4
    • 22
  • c

    codeslubber

    04/11/2020, 2:55 PM
    This was working fine under I think
    dev05
    but under 8 it says failed to cast to MutableState:
    *val* position = _state_ *{* _SliderPosition_(valueRange = sliderRange, initial = range.*first*.toFloat(), steps = 9) }
    a
    z
    m
    • 4
    • 24
  • k

    Kazemihabib1996

    04/11/2020, 10:22 PM
    Seems that samples are broken they show "
    //Unresolved: ...
    for example: https://developer.android.com/reference/kotlin/androidx/ui/layout/LayoutSize https://developer.android.com/reference/kotlin/androidx/compose/Pivotal
    l
    • 2
    • 1
  • a

    amar_1995

    04/12/2020, 1:42 AM
    I am trying to use TextField. In text field onBlur is not getting called. Am I doing somthing wrong. I am only using one text field.
    TextField(
        value = value,
        onValueChange = onValueChange,
        textStyle = editorStyle,
        imeAction = ImeAction.Search,
        keyboardType = keyboardType,
        onImeActionPerformed = {
            onSearchClick()
        },
        onFocus = {
            println("focus called >>>>")
            onSearchChanged(R.drawable.ic_baseline_arrow_back_24)
        },
        onBlur = {
            println("blur called >>>>")
        }
    )
    In above example
    blur called >>>>
    is never printed. Cursor is also not removed once it gain focus. In dev-05( I think) it was working fine but not now.
    • 1
    • 1
  • m

    molikto

    04/12/2020, 3:01 AM
    is it safe to create a static
    MutableState
    outside of any composition, then this state is shared among multiple compositions? Will this leak any Composition/Context?
    a
    • 2
    • 1
  • s

    Sri

    04/12/2020, 4:37 PM
    I was trying to create a row of buttons using the following code.
    @Composable
    fun ButtonRow() {
        Row {
            val padding = Modifier.padding(12.dp)
            Button(onClick = {  }, modifier = padding) {
                Text(text = "Ok")
            }
            Button(onClick = {  }, modifier = padding) {
                Text(text = "Subtract")
            }
        }
    }
    I am not able to center the
    Ok
    text. Any help as to what I have to do to center it would be much appreciated.
    a
    • 2
    • 1
  • k

    Kazemihabib1996

    04/12/2020, 8:07 PM
    I've been trying this animationDemo https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/SingleValueAnimationDemo.kt but I see no animation in that, the color directly changes from
    Color(0.0, 1.0, 0.0, 1.0, sRGB IEC61966-2.1)
    to
    Color(1.0, 0.0, 0.0, 1.0, sRGB IEC61966-2.1)
    @Composable
    fun SingleValueAnimationDemo() {
        val enabled = state { true }
        Clickable({ enabled.value = !enabled.value }) {
            val color = animate(if (enabled.value) Color.Green else Color.Red)
            Box(Modifier.fillMaxSize(), backgroundColor = color)
        }
    }
    v
    • 2
    • 6
  • t

    Timo Drick

    04/12/2020, 8:38 PM
    Most of the "controls" e.g.: FloatingActionButton, Slider, Circular/LinearProgressIndicator, Button using MaterialTheme.colors.primary as default color. But regarding to the documentation: https://material.io/design/color/the-color-system.html#color-theme-creation and also to the documentation of ColorPalette this kind of elements should use secondary color. Is it planned to change this in the future? Or how should we apply the color themes inside of an app? Currently i have to use custom buttons/controls which override the default color every where. Just because i want to stick to the material theme coloring recommendation.
    v
    m
    a
    • 4
    • 4
  • z

    zak.taccardi

    04/13/2020, 3:38 PM
    What role do Fragments (and to a lesser extent, the Navigation Component) play in a
    @Compose
    world?
    a
    • 2
    • 25
  • k

    Kazemihabib1996

    04/13/2020, 5:02 PM
    https://gist.github.com/kazemihabib/fb6ee75fc0da2528370d8452869953e9 I created a Solar System animation then for more fun I also added drawLayout demo of @Zach Klippenstein (he/him) [MOD] to it to see how drawLayout works with animated stuff 🙂 here is the result on specific rotations moon sometimes disappears I don't know the reason 🤔
    👍 11
    z
    • 2
    • 4
  • k

    Kstabks

    04/13/2020, 9:32 PM
    Hi, is there any plans to have compose running on android and iOS? So to have just separate library for android, iOS, maybe web (just like we have libraries for coroutines). Is it something possible?
    z
    • 2
    • 1
  • r

    romainguy

    04/14/2020, 5:55 AM
    Multi threaded composition isn't implemented yet
    m
    • 2
    • 2
  • k

    Kazemihabib1996

    04/14/2020, 6:46 PM
    Using
    TabRow
    inside
    VerticalScroller
    crashes:
    @Composable
    fun TextTabs() {
        var state by state { 0 }
        val titles = listOf("TAB 1", "TAB 2", "TAB 3 WITH LOTS OF TEXT")
        VerticalScroller {
            Column {
                TabRow(items = titles, selectedIndex = state) { index, text ->
                    Tab(text = { Text(text) }, selected = state == index, onSelected = { state = index })
                }
                Text(
                        modifier = Modifier.gravity(ColumnAlign.Center),
                        text = "Text tab ${state + 1} selected",
                        style = MaterialTheme.typography.body1
                )
            }
        }
    }
    I just added VerticalScroller to https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/TabSamples.kt?autodive=0%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F
    l
    • 2
    • 4
  • i

    ianrumac

    04/15/2020, 12:19 PM
    Hey everyone! I’ll be talking about compose (based on dev-08) at an online meetup later today, I suppose most of you will know the stuff I’m covering but if someone is into it, here’s a link: https://www.meetup.com/GDG-Osijek/events/269385300/
    👍 5
    g
    • 2
    • 1
  • f

    Foso

    04/15/2020, 5:55 PM
    dev09 is online, https://developer.android.com/jetpack/androidx/releases/compose
    🎉 21
    z
    • 2
    • 1
  • a

    Andrey Kulikov

    04/15/2020, 8:04 PM
    we forgot to mention in the release notes but dev09 also contains new artifact
    ui-livedata
    and
    ui-rxjava2
    with adapters for these streams (see commits: livedata, rx). we also hope to provide an adapter for
    Flow
    soon
    🙏 9
    👍 1
    z
    • 2
    • 4
Powered by Linen
Title
a

Andrey Kulikov

04/15/2020, 8:04 PM
we forgot to mention in the release notes but dev09 also contains new artifact
ui-livedata
and
ui-rxjava2
with adapters for these streams (see commits: livedata, rx). we also hope to provide an adapter for
Flow
soon
🙏 9
👍 1
z

Zach Klippenstein (he/him) [MOD]

04/15/2020, 8:17 PM
Why go through the indirection of returning a
State
, instead of just returning the value directly? Is it cheaper to “observe” a single model instance’s property multiple times than run this subscription/observation wiring multiple times?
I’m guessing the former involves fewer (no?) extra allocations?
a

Andrey Kulikov

04/15/2020, 9:01 PM
Returning raw values causes a frame read to happen as part of returning the value from the subscription function, causing the surrounding scope to recompose for value changes. By returning the underlying State<T> instead we can limit the scope of recompositions while sharing the subscription to different parts of the composition subtree. Plus this state can be used in draw or layout lamdas allowing us to skip recomposition and one redraw when the new value emitted. The syntax is the same as with a regular
state { }
, and similarly to it property delegation using
by
makes it easy to simplify the basic usages
z

Zach Klippenstein (he/him) [MOD]

04/15/2020, 10:37 PM
Cool, thanks for the explanation!
View count: 1