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

    vanpra

    07/02/2020, 9:29 PM
    I've implemented a date and time picker dialog in compsoe (https://github.com/vanpra/ComposeDateTimePicker) but for some reason it seems to skip a few frames when I show the dialog. I think this might be due to my hacky implementation of ViewPager for the date picker, so is there any way that I could improve it and make it more efficient? Currently I just Have a HorizontalScroller with 3 pages, one in the centre and one left and right of it and then when the user swipes right I animate it as they drag and when it reaches the boundary I snap it back to the centre. I find that when I'm rendering a simple layout on the pages it works fine but when I use it for the date picker it's a bit laggy.
    s
    a
    • 3
    • 7
  • l

    Lilly

    07/03/2020, 12:36 AM
    Hi, Is it possible to have state
    val isScanning: Boolean by viewModel.isScanning.collectAsState() // viewModel.isScanning is of type StateFlow<Boolean>
    without an initial value? I have multiple locations where this behaviour makes me trouble. Or to be more concrete: When I write something like this below my state:
    if (isScanning) viewModel.stopScan() else viewModel.startScan()
    it should not trigger
    stopScan()
    nor
    startScan()
    when composable function is called. Instead it should trigger on next value change.
    l
    t
    s
    • 4
    • 6
  • a

    allan.conda

    07/03/2020, 10:13 AM
    Trying to work with ViewModel and Compose, I’m not sure which one would be the preferred approach. Anyone have opinions on this? I’m worried the first one is inefficient, unless Compose somehow only recomposes the updated value (such as username)
    Untitled
    a
    l
    +2
    • 5
    • 14
  • r

    rajesh

    07/03/2020, 1:40 PM
    I'm facing this error while using Android studio 4.2 canary 3 and compose 0.1.0-dev14 with kotlin 1.4-M2 and getting this error while gradle building Class 'Kotlin.Unit' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler. Any help is appreciated.
    a
    j
    +2
    • 5
    • 7
  • n

    nglauber

    07/03/2020, 6:08 PM
    I don’t make questions here for a while, then sorry if this is a FAQ, but here it goes… Why margin is not a modifier like padding is? 🤔
    ☝️ 1
    l
    a
    +5
    • 8
    • 75
  • j

    Joe Masilotti

    07/03/2020, 11:42 PM
    In the JetNews sample application in `Navigation.kt:98`:
    This is expected to be replaced by the navigation component, but for now handle navigation manually.
    What is “the navigation component?”
    v
    t
    • 3
    • 7
  • r

    romainguy

    07/04/2020, 4:48 AM
    It's now
    LazyColumItems
    n
    • 2
    • 5
  • n

    nglauber

    07/04/2020, 2:16 PM
    New question/feedback 😛 This is a simple `FilledTextField`… 1. Don’t you think the default background color should be transparent? 2. Don’t you think the start padding (or inner space 😅 between the border and the hint) is too big? 3. I can’t type using the laptop keyboard, I have to press the keys on the virtual keyboard… is this the [current] expected behavior?
    a
    h
    • 3
    • 8
  • j

    Joe Masilotti

    07/04/2020, 2:43 PM
    Am I missing something obvious or is there only one (official) tutorial and one code lab for Compose? I’m trying to learn how to use a toggle/switch and really not sure where to start. The main marketing page only links to SO, this Slack group, and a big tracker.
    a
    b
    +2
    • 5
    • 7
  • d

    dhimandasgupta

    07/04/2020, 5:59 PM
    It there any api to render html in a Text? And I don’t need to worry whether the content is plain text or html. Below is a screen shot from my sample and snippet what I am using to generate the view
    @Composable
    fun RenderArticle(article: ArticleUIModel) {
        Divider(thickness = 8.dp, color = MaterialTheme.colors.surface)
        Surface(shape = shapes.medium, elevation = 8.dp, color = MaterialTheme.colors.surface, modifier = Modifier.fillMaxWidth()) {
            Column(modifier = Modifier.padding(8.dp)) {
                Text(
                    text = article.title,
                    style = MaterialTheme.typography.h6,
                    color = MaterialTheme.colors.onSurface,
                    modifier = Modifier.padding(bottom = 4.dp)
                )
                Divider(thickness = 2.dp, color = MaterialTheme.colors.surface)
                Text(
                    text = article.description,
                    style = MaterialTheme.typography.body1,
                    color = MaterialTheme.colors.onSurface,
                    modifier = Modifier.padding(top = 4.dp)
                )
            }
        }
        Divider(thickness = 8.dp, color = MaterialTheme.colors.surface)
    }
    p
    • 2
    • 3
  • s

    Sergey Y.

    07/04/2020, 10:20 PM
    Hi everyone. Does Compose already have something similar to
    Hero Animation
    from
    Flutter
    or
    Shared Element Transition
    from
    Android SDK
    ?
    v
    • 2
    • 1
  • n

    nglauber

    07/05/2020, 2:58 PM
    How can I change my state without pass a callback deep down into my composable “hierarchy”. I mean… I have a state on my composable
    A
    and this composable calls
    B
    which calls
    C
    . Is there a way to change the state in
    C
    ? When we had
    @Model
    we just need to update attribute and it worked…
    👀 1
    a
    • 2
    • 3
  • a

    AG

    07/05/2020, 3:40 PM
    Hello, can someone help me to figure out how to make
    LazyRowItems
    with
    wrap content
    inside
    LazyColumnItems
    work correctly. In this example I have a row with images where each image has width 100dp. When I’m not passing modifier value with height in
    LazyRowItems
    it shows only one row and Text is not rendering , also it’s possible to scroll the page, but when I’m passing modifier with
    preferredHeight
    all works correctly,
    wrapContentHeight
    not working also.
    LazyColumnItems(items = List(size = 30, init = { it })) { column ->
        if (column % 2 == 0) {
            LazyRowItems(
                items = List(size = 30, init = { it })
                //modifier = Modifier.preferredHeight(100.dp)
            ) { row ->
                Image(
                    asset = imageAsset,
                    modifier = Modifier.wrapContentHeight(100.dp).aspectRatio(1f)
                )
            }
        } else {
            Text(text = "$column")
        }
    }
    a
    • 2
    • 2
  • n

    nglauber

    07/05/2020, 5:37 PM
    New question 😛 : Is there a way to save the scroll position of a
    LazyColumnItems
    ? I’m using a
    TabRow
    to display two tabs and each one display a list of content. When I swap between the tabs, the scroll position of the list is lost.
    👍 3
    t
    • 2
    • 6
  • a

    andylamax

    07/05/2020, 11:12 PM
    Is there a current implemented NavigationDrawer in compose?
    v
    • 2
    • 1
  • b

    Brady Aiello

    07/06/2020, 12:06 AM
    Yes
    m
    • 2
    • 1
  • m

    Madhava

    07/06/2020, 1:01 AM
    Does anyone know if the MaterialTheme or Ripple effects can be disabled. They seem to be quite laggy on the current versions and I was wondering if they can simply be turned off to improve performance?
    r
    a
    • 3
    • 14
  • h

    Harish Gupta

    07/06/2020, 2:46 AM
    Hi, Is there any way to set different background colors for the surface composable from the one defined in the color palette in the material theme? All surface composable background takes the same color as declared in the theme, but what if I want to have a different background color for different surface composable.
    r
    • 2
    • 3
  • a

    allan.conda

    07/06/2020, 9:47 AM
    Want to use savedInstanceState extension in a Compose fragment and realized it doesn’t work. Anyone who tried it and made it work?
    m
    a
    +5
    • 8
    • 15
  • b

    bohregard

    07/06/2020, 1:56 PM
    Is there a maxHeight constraint? I could’ve swore there was one before, but now I can’t seem to find anything related to max height/width just min.
    b
    • 2
    • 2
  • j

    Joost Klitsie

    07/06/2020, 2:04 PM
    The
    BaseComponent
    in itself basically is a lifecycleOwner, observes the parent's lifecycleowner (so copies those and will call on_destroy when onDispose is called on itself) and creates the dependency graph (by extending the parent's dependency graph). Does anyone have any pointers here? 🙂
    f
    l
    • 3
    • 46
  • b

    Bacho Kurtanidze

    07/06/2020, 2:37 PM
    is there any way to replace one composable function with another one with some kind of transition(Fading or Sliding)?
    a
    • 2
    • 1
  • a

    aipok

    07/06/2020, 5:58 PM
    does anyone have a good sample on how to build a dropdown list? I can see
    Dropdown
    composable, but how to put everything together inside it is not clean. How to track selected item and modify it on select
    v
    • 2
    • 15
  • o

    ofalvai

    07/06/2020, 7:10 PM
    Hey 👋 I ran into an edge case with Compose, and I’m not sure where to start debugging this. I created a simple composable UI that works fine on emulator, my device, even in Android Studio preview. But I’d like use it in combination with Android 11's Quick Access Device Control feature. When the user long presses on any system control, my own Activity is launched (this is where I use Compose) as something like a bottom sheet dialog with the Activity inside. And this is where my Compose UI breaks, because I can’t interact with anything inside the Activity, nothing reacts to any user input. Things that I’ve tried: • using a regular XML layout in this Activity -> every View is tappable, responds to input • using Compose in this Activity, but launching it as a regular Activity -> also OK Any ideas what’s the issue? Is it Compose, or the Android 11 Beta? Or some weird combination of both?
    👀 1
    • 1
    • 1
  • a

    Ankur Gupta

    07/06/2020, 7:51 PM
    Hey, how can I change the color of shadow produced by
    drawShadow()
    modifier? I’m trying to make neumorphism design components. It would be great to have more control on shadows similar to the
    box-shadow
    property in CSS.
    👀 1
    👍 2
    l
    s
    +4
    • 7
    • 50
  • b

    bohregard

    07/06/2020, 9:17 PM
    So when using AndroidView in the latest release, is there a way to get the view to “update”? Say for instance I’m using a custom AndroidView from a library that has buttons, changing text, whatever, compose will never recompose those views. They just have the last state (or sometimes the initial state) when it was drawn last. A good example is ExoPlayer’s PlayerView (which has the built in PlayerController which is never updated with information about the currently playing video. (The surface view works great though).
    j
    a
    m
    • 4
    • 9
  • v

    vanpra

    07/07/2020, 3:06 PM
    How does compose handle components that are out of view (ie. off the left or right of a view). Does it just ignore them until they are on visible?
    l
    r
    • 3
    • 2
  • z

    zak.taccardi

    07/07/2020, 4:13 PM
    Does
    @Compose
    support side effects, like launching a dialog or a
    Snackbar
    that auto-dismisses itself after a short time?
    s
    b
    • 3
    • 13
  • c

    chris

    07/07/2020, 4:30 PM
    Work for a company that has to whitelist all artifacts we use and create local copies in artifactory. For these items
    composeOptions {
            kotlinCompilerVersion "1.3.70-dev-withExperimentalGoogleExtensions-20200424"
            kotlinCompilerExtensionVersion "0.1.0-dev13"
        }
    Where is that resolved from? Is it packaged with Studio?
    s
    • 2
    • 1
  • r

    romainguy

    07/07/2020, 4:33 PM
    Yes
    c
    • 2
    • 3
Powered by Linen
Title
r

romainguy

07/07/2020, 4:33 PM
Yes
c

chris

07/07/2020, 4:35 PM
So is there a workaround available to me if I'm still on 4.1 canary 10?
They have yet to make the 4.2 canary available to us
r

romainguy

07/07/2020, 4:51 PM
You can only use the version of Compose that comes with 4.1 Canary afaik
View count: 1