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

    Radoslaw Juszczyk

    03/09/2021, 7:35 PM
    hello everyone, I am just starting composing… is there a way to put a ripple effect on a
    Surface
    ? I have tried:
    Surface(modifier=Modifier.clickable(indication=….))
    but
    indication
    is not resolved what is the correct way to do that?
    l
    l
    • 3
    • 7
  • d

    Dan Peluso

    03/09/2021, 8:13 PM
    Hey guys! Just started using compose in a live-graph implementation which uses an existing view that live updates from values being produced from Rx. Has anyone had issues with their app freezing due to updating views frequently within the main compose view? Code in thread
    s
    • 2
    • 4
  • f

    Francois Morvillier

    03/09/2021, 8:16 PM
    Hi! Does Compose have a simple or idiomatic way to create a button which calls an onPressed function every N milliseconds as long as it remains pressed?
    • 1
    • 1
  • t

    Tiago Taraczuk

    03/09/2021, 9:58 PM
    Hi folks, I have noticed that the
    Text
    have some
    padding top
    by default. Anyone knows how to remove it?
    s
    a
    • 3
    • 2
  • a

    alexandrepiveteau

    03/09/2021, 10:08 PM
    Hey ! I was wondering - is there any reason for which `androidx.compose.ui.layout.ContentScale`is not a
    fun interface
    ?
    l
    n
    • 3
    • 2
  • m

    maciejciemiega

    03/09/2021, 10:31 PM
    I’ve just submitted my “Newton’s Timer” for Week 2 of #AndroidDevChallenge ✌️ https://twitter.com/MaciejCiemiega/status/1369403866454896652
    video2.mp4
    👍 15
    🤩 21
    🎉 38
    :kotlin-intensifies: 24
    c
    t
    +2
    • 5
    • 8
  • m

    Mehmet Peker

    03/09/2021, 10:45 PM
    what is the equivalent of ValueAnimator on jetpack compose?
    r
    z
    l
    • 4
    • 8
  • b

    bohregard

    03/10/2021, 12:23 AM
    is
    onGloballyPositioned
    supposed to be called more than once after a layout? Or is supposed to only be called once it’s positioned? I ask because I have a composable that is constantly calling
    onGloballyPositioned
    despite not moving or recomposing (at least to my knowledge).
    l
    • 2
    • 6
  • t

    Tim Malseed

    03/10/2021, 12:43 AM
    Hey all, I’m using the Material ListItem ‘trailing’ property, and trying to align my trailing content in a column.. with difficulty
    c
    • 2
    • 7
  • t

    therealbluepandabear

    03/10/2021, 1:27 AM
    Is it possible to make games in compose? Or is Unity more for that stuff?
    r
    • 2
    • 5
  • c

    Colton Idle

    03/10/2021, 1:48 AM
    Repost of an earlier question that didn't get much traction, but I want to make sure I'm not missing something. Does compose material give you a "toggle button group" composable like this out of the box like the legacy view system?
    l
    r
    • 3
    • 5
  • d

    Dan Peluso

    03/10/2021, 2:36 AM
    (RxJava3) If you're creating an observable to emit values and subscribing in your composable with
    subscribeAsState()
    , is there a way to unsubscribe from that? Code in thread
    l
    • 2
    • 10
  • b

    bohregard

    03/10/2021, 3:17 AM
    What would cause this exception? I’ve narrowed it down to an ExoPlayer view, but the problem is I don’t know why it’s doing it
    a
    • 2
    • 4
  • s

    Slackbot

    03/10/2021, 4:10 AM
    This message was deleted.
    :thread-please: 1
    d
    • 2
    • 2
  • e

    eygraber

    03/10/2021, 6:33 AM
    My app sometimes crashes when I change code in the IDE. There's a large tombstone and some java stacktrace about trying to attach an agent, etc... A HotReloader is mentioned a few times. Is that something that can be disabled, because it's very annoying.
    l
    a
    • 3
    • 4
  • j

    Jason Ankers

    03/10/2021, 7:47 AM
    How can I make a
    Row
    wrap its content, but have a max width of half its parent?
    y
    • 2
    • 1
  • a

    allan.conda

    03/10/2021, 7:50 AM
    Is it possible for a child composable to ignore the padding of the parent?
    d
    • 2
    • 2
  • t

    Tin Tran

    03/10/2021, 8:44 AM
    Does anyone knows how
    item{}
    works in LazyColumn? I’m having a weird issue with it If i have 2
    item
    block inside a LazyColumn when i scroll pass the all the elements in the first item block and scroll back to it, all the composable in the first item block got recomposed even if the data haven’t changed.
    a
    a
    • 3
    • 13
  • d

    Damien

    03/10/2021, 9:00 AM
    The width of the first element fluctuates when using fillParentMaxSize inside a LazyRow, is it a bug or am I doing something wrong?
    • 1
    • 1
  • n

    Nathan Castlehow

    03/10/2021, 9:11 AM
    Hi, I have some properties on my view model which my view subscribes to. One of these is created by “derivedStateOf”. I am trying to keep my view light so when this derived state changes i need to do a bunch of steps inside in a function in my view modell. Is there any way to subscribe to “derivedStateOf” inside a view model (ie outside of the composable) or do i need to instead make these properties a flow so i can subscribe to them both inside and outside of a composable? Thanks!
    a
    • 2
    • 9
  • d

    Deepak Gahlot

    03/10/2021, 10:21 AM
    So i'm using a ModalBottomSheetLayout inside an LazyColumn. The Modalsheet comes up on the button click which is one of the item of the LazyColumn. And i'm getting this error
    java.lang.IllegalStateException: Nesting scrollable in the same direction layouts like ScrollableContainer and LazyColumn is not allowed.
    a
    j
    s
    • 4
    • 15
  • m

    Marko Novakovic

    03/10/2021, 12:01 PM
    when working with
    NavigationComponenet
    and
    BottomNavigation
    I have a problem with tabs being selected (code in thread)
    n
    • 2
    • 9
  • o

    Orhan Tozan

    03/10/2021, 1:45 PM
    My indeterminate progress indicator keeps re-starting, looks it keeps switching to it's initial state after a second. How should I combat this?
    CircularProgressIndicator()
    l
    • 2
    • 1
  • e

    eygraber

    03/10/2021, 2:06 PM
    I have a very naive algorithm to generate an hsv color palette by using a nested loop to walk through each pixel, calculate the correct color for it, and then draw it to a canvas (using Painter), and then creating an Image for it. The problem is that it doesn't scale well for sizes larger than a few hundred pixels. Is there a more performant API I can use in common compose, or would I have to delegate to the platforms (Android and desktop in this case)?
    l
    • 2
    • 2
  • m

    martinsumera

    03/10/2021, 2:36 PM
    I’m trying to grasp how the lifecycle for the composables works comparing to the traditional lifecycle of activity or fragment. Let’s say that I have functionality that is fetching data from the backend every second while the screen is visible. For example, with activity/fragment I would start fetching data in onResume and I would stop it in onPause. How should I implement such functionality with Compose? When I’m using navigation components then viewmodel is still alive even when another screen is pushed above the one that should be stopped. Could somebody explain this to me? Thanks.
    g
    • 2
    • 3
  • s

    Slackbot

    03/10/2021, 2:57 PM
    This message was deleted.
    e
    d
    • 3
    • 2
  • m

    Mahdi Safarmohammadloo

    03/10/2021, 3:59 PM
    Hi Guys ! why my simple state handling isn't working ?
    class Core {
        val texts:MutableList<String> = mutableListOf("Salam !","Hello World !")
        fun add (text:String):Core{
            texts.add(text)
            return this
        }
    }
    fun main() = Window {
        var core by remember { mutableStateOf(Core()) }
        MaterialTheme {
            Button(onClick = {
                core = core.add("salam ! salam !")
            }) {
                Column {
                    core.texts.map {
                        Text (it)
                    }
                } } } 
    }
    f
    c
    • 3
    • 7
  • s

    Shakil Karim

    03/10/2021, 4:34 PM
    Hi, I'm trying to use rememberSaveable with Enum but it's not working, not sure what I'm doing wrong here.
    s
    a
    • 3
    • 4
  • d

    Deepak Gahlot

    03/10/2021, 4:41 PM
    So while clicking on any of the clickable component in Compose, i see that there is a grey color bar comes up for a sec, can we customise that effect, may be to a different color
    Screen Recording 2021-03-10 at 10.08.43 PM.mov
    l
    • 2
    • 5
  • d

    David Edwards

    03/10/2021, 4:58 PM
    I am currently attempting to refresh data from a server at a regular interval, only when the UI is displayed. So when back or home is pressed, the checks will stop. When I return, it will continue again. I thought I could use a LaunchedEffect, as it runs in a CoroutineScope. I thought that this would result in the Coroutine automatically cancelling when going home. However, I am not sure how it is linked to the lifecycle. It remains active in the background.
    LaunchedEffect(true) {
        while (isActive) {
            delay(60000L)
            vm.getData()
        }
    }
    Is there a better pattern to use in this case?
    a
    • 2
    • 5
Powered by Linen
Title
d

David Edwards

03/10/2021, 4:58 PM
I am currently attempting to refresh data from a server at a regular interval, only when the UI is displayed. So when back or home is pressed, the checks will stop. When I return, it will continue again. I thought I could use a LaunchedEffect, as it runs in a CoroutineScope. I thought that this would result in the Coroutine automatically cancelling when going home. However, I am not sure how it is linked to the lifecycle. It remains active in the background.
LaunchedEffect(true) {
    while (isActive) {
        delay(60000L)
        vm.getData()
    }
}
Is there a better pattern to use in this case?
a

Adam Powell

03/10/2021, 5:24 PM
This will remain active in the background, yes. There are a few new APIs in flight for
androidx:lifecycle:lifecycle-ktx
that will look more like:
LaunchedEffect(true) {
  repeatOnLifecycle(Lifecycle.State.STARTED) {
    while (true) {
      delay(...)
      vm.getData()
    }
  }
}
d

David Edwards

03/10/2021, 5:25 PM
Ahhh, that will be great. I look forward to it. 👍
👍 1
Has anything landed yet for this purpose?
a

Adam Powell

04/20/2021, 4:45 PM
yes https://developer.android.com/reference/kotlin/androidx/lifecycle/package-summary#repeatonlifecycle
🙌 1
d

David Edwards

04/20/2021, 4:53 PM
For other interested parties, it was added in
2.4.0-alpha01
. I didn't notice a new alpha version.
View count: 2