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

    Daniel

    03/01/2021, 7:05 PM
    I'm planning on filing a bug suggesting that
    PointerInputScope.awaitFirstDown
    should have an inverse, but I wanted to check if anyone saw anything obvious I was missing first.
    private suspend fun PointerInputScope.awaitChangedToUp(id: PointerId) {
        awaitPointerEventScope {
            do {
                val event = awaitPointerEvent().changes.fastFirstOrNull { it.id == id }
                event?.consumeAllChanges()
            } while (event?.changedToUp() != true)
        }
    }
    t
    • 2
    • 22
  • g

    Gabriel

    03/01/2021, 7:19 PM
    https://developer.android.com/jetpack/compose/state talks about observeAsState, is that outdated and is now collectAsState ?
    b
    • 2
    • 5
  • s

    Simone Summo

    03/01/2021, 7:56 PM
    I’m theming my app, but the status bar doesn’t follow the colors
    b
    s
    +2
    • 5
    • 5
  • t

    Tony Kazanjian

    03/01/2021, 9:03 PM
    Are there any examples of how to implement an auto-scrolling mechanism within a Modifier's
    .scrollable()
    , or else, y'know, anywhere? Looks like I would need a custom implementation of
    ScrollableState
    interface for the modifier
    d
    • 2
    • 1
  • i

    Issa

    03/01/2021, 9:33 PM
    Hi Everyone! I hope you’re all doing great and being safe. I just pulled
    beta01
    and I am having troubles figuring out what happened to
    SwipeableConstants.DefaultAnimationSpec
    ? I couldn’t find anything relevant in the release notes or maybe I overlooked it. Does anyone knows where to find it? previously it was in
    material
    artifact. Thanks in advance
    l
    • 2
    • 7
  • g

    Gabriel

    03/01/2021, 9:58 PM
    I'm having a weird crash, an alert dialog with a textfield and some state to decide whether the alert is open, dismissing the dialog without editing anything in the textfield works ok, after I edit the textfield dismissing the dialog crashes the app
    java.lang.ArrayIndexOutOfBoundsException: length=5120; index=-2
            at androidx.compose.runtime.SlotTableKt.groupSize(SlotTable.kt:2558)
    i
    s
    j
    • 4
    • 8
  • s

    Sam

    03/01/2021, 10:07 PM
    Does anyone have clear guidance for
    onActive
    and
    onDispose
    ? We went from clear semantic names to
    DisposableEffect
    and i have no idea what to pass in as a parameter..
    j
    j
    +4
    • 7
    • 22
  • j

    Jordi Saumell

    03/01/2021, 10:09 PM
    I’ve noticed my LazyColumn loses scroll position when I go to another screen and come back (I believe in a previous version of Compose it worked with the same code). It is because when I come back to the screen the list is empty (and shortly after it gets loaded), so it overwrites the scroll position that was saved in LazyListState. My workaround is to not call LazyColumn if there are no items… Is there a better way of doing this? And is this the intended behaviour?
    a
    • 2
    • 1
  • p

    Piotr Prus

    03/01/2021, 10:28 PM
    I am trying to add space between 2 columns (elements) in my
    LazyVerticalGrid
    . So far, no luck. contentpadding is used for padding around whole lazyGrid, not individual item. In
    LazyColumn
    , there is a parameter called verticalArrangement which can be used to add spacer between elements, but how can I do that for Grid?
    a
    t
    • 3
    • 5
  • d

    Daniel

    03/01/2021, 10:52 PM
    I narrowed my issue down to what seems to be a bug in navigation-compose. I filed a bug: https://issuetracker.google.com/issues/181576281
    i
    • 2
    • 2
  • z

    Zach Klippenstein (he/him) [MOD]

    03/02/2021, 12:04 AM
    We just released an update to Radiography (v2.3.0)– most notably, it now supports Compose Beta 1! Radiography can be helpful when you need to see a readable printout of your UI but don’t have access to something like Android Studio’s Layout Inspector or other interactive tools.
    👍 16
    t
    • 2
    • 4
  • i

    Isaac Udy

    03/02/2021, 12:15 AM
    Does anyone know when Compose will be supported by a non-canary (beta or stable) version of Android Studio? The requirement to use the canary version makes it very difficult to adopt in a large project with multiple teams. It would be nice to be able to test it out in one module without forcing everyone to use AS canary.
    c
    a
    +3
    • 6
    • 13
  • k

    knthmn

    03/02/2021, 4:38 AM
    In https://developer.android.com/jetpack/compose/interop#case-study-broadcastreceivers, the example shows tying a broadcast receiver to the lifecycle of a composable. However (if I understand it correctly), a composable follows the lifecycle of
    onCreate
    and
    onDestroy
    (and as long as it is in scope). Is there something I can do to tie it to
    onStart
    and
    onStop
    ?
    i
    • 2
    • 2
  • s

    Spikey Sanju

    03/02/2021, 6:36 AM
    Hey guys, Does
    Jetpack compose navigation
    component do
    animation
    on
    screen transition
    ?... Like Slide in left, slide out right?
    a
    m
    m
    • 4
    • 7
  • s

    Samir Basnet

    03/02/2021, 8:59 AM
    I asked it yesterday but nobody's answering. When using dropdown inside a Box the popup starts with box parent but the end goes to end of the screen . I am using fillMaxWidth in Dropdown modifier. Is there any way to limit it's end also to its parent????
    l
    j
    • 3
    • 4
  • m

    Mehdi Haghgoo

    03/02/2021, 9:11 AM
    We don't need to mention useIR=true in build.gradle anymore, do we?
    f
    z
    • 3
    • 5
  • a

    allan.conda

    03/02/2021, 9:11 AM
    Has the default behaviors of ImeActions in Text worked for anyone? Seems it has never worked since compose-dev. Still not working in beta01
    r
    j
    +2
    • 5
    • 12
  • j

    julioromano

    03/02/2021, 10:18 AM
    How to call
    NavController
    from
    Activity.onNewIntent()
    ?
    a
    i
    • 3
    • 7
  • f

    FunkyMuse

    03/02/2021, 11:22 AM
    Hey guys, did someone manage to make Downloadable Fonts work for Compose?
    ➕ 1
    c
    • 2
    • 1
  • s

    Stylianos Gakis

    03/02/2021, 12:05 PM
    Hey people, I have a question. How do you usually go through the process of "I want to do X" while working with Compose? So far when I want to do something, I've been trying to google for it, but the google results are almost always very bad. This is natural, with all the stackoverflow posts, blogs etc. covering how to do some stuff in the previous versions which are very often deprecated. I am sure this will get better as we have a more stable API now, but right now it's very challenging for me. For example now, I wanted to look into making a bottom sheet, but not one that expands fully like the one
    BottomSheetScaffold
    provides, just have it appear at let's say 30% of the screen and be able to swipe it down again. After trying to search for it, or even trying out some ideas myself I feel like I very often end up in dead-ends (and not just this bottom sheet idea, anything non-trivial I try to achieve). This is not something that I had experienced when working with non-compose Android before due to the massive amount of information that there is online. Any advice on how to approach this?
    👍 1
    t
    a
    +4
    • 7
    • 12
  • r

    Rasul Aghakishiyev

    03/02/2021, 12:43 PM
    I'm super excited to announce my first plugin for Intellij Idea and Android Studio. It allows you easily wrap your Composable with Row, Column and etc. You can download it by link below https://plugins.jetbrains.com/plugin/16174-wrap-compose or from Plugins section in Android Studio or Intellij Idea Hope it will make your development easier and more enjoyable If you have any questions please leave it on twit below: https://twitter.com/a_rasul98/status/1366396862538928128 Have a great day!
    :kotlin-intensifies: 5
    🙏 1
    👍 3
    d
    c
    z
    • 4
    • 4
  • z

    zoha131

    03/02/2021, 1:01 PM
    Is there any way to Align Composables based on Text’s baseline?
    l
    • 2
    • 6
  • e

    Eric Martori

    03/02/2021, 1:15 PM
    Maybe it is already asked but I can't find an answer. It seems that
    navigation-compose
    has dependencies to non-compose Android libraries. Ideally a Compose navigation library should be agnostic of the underlying platform, right? Is there any alternative that doesn't depend on Android code to implement the navigation?
    s
    a
    • 3
    • 2
  • a

    Archie

    03/02/2021, 1:28 PM
    Hi Guys, how do you check whether NavController have something in the backstack?
    i
    b
    j
    • 4
    • 8
  • w

    wiktorl4z

    03/02/2021, 1:50 PM
    Hey, I want to learn compose and I am reading documentation for example: https://developer.android.com/jetpack/compose/lists Looks nice but reading sample code I can't see method MessageRow or PhotoItem and so one.. Would like to see how code looks like for it aswell. Is there any place where I can find missing code?
    a
    l
    • 3
    • 3
  • l

    Lukasz Burcon

    03/02/2021, 1:51 PM
    Do you guys have any idea on how to intercept back press when user’s editing text and keyboard is being shown? Can’t find a way to intercept the back press, the keyboard just gets hidden.
    OnBackPressedDispatcher
    doesn’t seem to help
    i
    r
    • 3
    • 3
  • m

    Michal Jezierski

    03/02/2021, 1:59 PM
    Hi Guys, I have problems with animation, some time ago I created kind of pager with custom transition, 2 cards are switched using changing alpha of backgrounds and content (quite complex) slide in/out (using absoluteOffset modificator), I created it using AnimatableFloat and everything was great 🙂 after upgrade from alpha11 to 12 some performance issues appeared, now on beta01 it is terrible and not working at all. I migrate it to Animatable and if I use card with image on backgrount and only single Text it works correctly, in case of complex card layout it freeze whole app. Does anyone have an idea why this happened and how to solve it?
    s
    d
    • 3
    • 2
  • a

    Archie

    03/02/2021, 3:30 PM
    Is there any way to add a
    footer
    to a
    LazyColumn
    so that if the items inside a
    LazyColumn
    doesn't consume all available space, the
    footer
    will be pinned at the bottom of the
    LazyColumn
    but if the items fill all the available space, the
    footer
    would act as a normal
    LazyColumn
    item?
    a
    • 2
    • 6
  • c

    Colton Idle

    03/02/2021, 4:06 PM
    My search skills are failing me. Does anyone have the link to the post here where someone built a custom tab indicator switcher animation. It was a circular outline of the selected item, and when you selected the next item, the circle opened up and transitioned to circle the new item?
    a
    n
    • 3
    • 4
  • r

    rsktash

    03/02/2021, 4:44 PM
    [SOLVED]: There is bug with
    Path.op
    methods (
    androidx.compose.ui.graphics.Path
    ). The method is ignoring last param options. All of them
    difference
    ,
    intersect
    reverseDifference
    doing
    union
    path
    r
    n
    +2
    • 5
    • 32
Powered by Linen
Title
r

rsktash

03/02/2021, 4:44 PM
[SOLVED]: There is bug with
Path.op
methods (
androidx.compose.ui.graphics.Path
). The method is ignoring last param options. All of them
difference
,
intersect
reverseDifference
doing
union
path
@jim
This android view snippet
This is compose view snippet
r

romainguy

03/02/2021, 5:09 PM
@Nader Jawad
r

rsktash

03/02/2021, 5:09 PM
I think the issue is originating from skija lib
n

Nader Jawad

03/02/2021, 5:10 PM
Looks like you're doing the path op but drawing a different path parameter
r

rsktash

03/02/2021, 5:11 PM
Yes I tried with all options but it is drawing with union operation
r

romainguy

03/02/2021, 5:14 PM
Do you have the issue with Compose Desktop or on Android?
If Compose Desktop it might be an issue in skija/skiko
r

rsktash

03/02/2021, 5:17 PM
First i tested with AS preview. Now I’m testing with android device
The same with android device
Maybe there is issue with binding?
d

dector

03/02/2021, 5:28 PM
I think you need to use
addRect()
instead of
drawRect()
🙂
👍 1
n

Nader Jawad

03/02/2021, 5:29 PM
Oh that's a good point, the calls in the apply method for the path should be path operations not drawing calls as part of the drawScope receiver scope
r

romainguy

03/02/2021, 5:30 PM
Good catch :)
r

rsktash

03/02/2021, 5:32 PM
@dector 🙈 Thank you
n

Nader Jawad

03/02/2021, 5:35 PM
One thing to note is that this is a good opportunity to leverage
Modifier.drawWithCache
as it breaks up the drawing operation into 2 steps that can be used to conditionally allocate and cache paths instead of allocating them on each draw call. Because the initial scope of drawWithCache isn't a DrawScope it makes it more difficult to call into drawing APIs instead of path operations
r

rsktash

03/02/2021, 5:36 PM
Thank you @Nader Jawad too. I’ll try it
@Daniel
👍 1
@Nader Jawad Is there a sample or doc for
Modifier.drawWithCache
d

Daniel

03/02/2021, 5:45 PM
@Nader Jawad @jvmusin. I've found drawWithCache super confusing
I initially thought it was broken, then happened to hear in a stream (by Leland Richardson) that it only cached calls in the initial draw with cache scope, not in the drawBehind/drawWithContent calls. The documentation is not at all clear about that
I also have an issue where it isn't invalidating if a state read in the cache scope is read. I'm not sure if that's intended behavior or not
n

Nader Jawad

03/02/2021, 5:47 PM
drawWithCache does invalidate the cache on state reads as well
d

Daniel

03/02/2021, 5:48 PM
let me try and repro and file a bug then
n

Nader Jawad

03/02/2021, 5:48 PM
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/DrawModifierSample.kt;l=51?q=drawModifierSample%20
We have a few samples of the usage here. It is used a lot in the implementation of compose and simplifies a lot of remember/boilerplate code as well. The cached parameters will be reused unless either the size changed or a state parameter that is read has changed
:thank-you: 1
d

Daniel

03/02/2021, 5:58 PM
It was my mistake. I had a call to graphicsLayer higher up in the modifier chain, and I didn't realize that would interfere. Reading the docs a second time though its clear that's expected behavior
n

Nader Jawad

03/02/2021, 5:59 PM
This should also be supported in graphicsLayer usages as well
d

Daniel

03/02/2021, 6:04 PM
Thanks for letting me know @Nader Jawad. I filed a bug with a repro project. https://issuetracker.google.com/issues/181589173
👀 1
n

Nader Jawad

03/02/2021, 6:10 PM
Thanks! Will take a look
👍 2
View count: 6