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

    TheMrCodes

    03/31/2021, 9:04 PM
    Bug? :ladybug:*:
    BoxWithConstraints
    update lag* Can someone confirm the stange flickering occuring om the content inside the
    BoxWithConstraints
    and that it's gone wenn replaced by a regular Box? Code in the 🧵
    z
    • 2
    • 15
  • c

    Colton Idle

    03/31/2021, 10:29 PM
    How to use AS stable with Compose: https://marcellogalhardo.dev/posts/2021/03/30/using-compose-beta-on-as-4-1/ I haven't tried it yet, but it would be nice to get a blessing/official documentation on how to do this. A lot of people I've spoken too have said that they want to adopt compose, but don't want to force canary or AGP 7 if they don't have to.
    j
    m
    +2
    • 5
    • 50
  • a

    Alex

    04/01/2021, 7:35 AM
    Can I query a composable for its height and width dimensions? The use case is downloading an image in a specific size (to save bandwidth). In standard Android I would do something like
    view.onLayoutDone { view ->
      downloadImageWith(view.width, view.height)
    }
    Extremely simplified of course, but you get the idea.
    a
    • 2
    • 1
  • a

    adauguet

    04/01/2021, 10:51 AM
    Is it possible to use only one activity and
    @Composable
    functions? Do I have do use fragments?
    f
    g
    a
    • 4
    • 8
  • n

    Nthily

    04/01/2021, 11:13 AM
    Hi, I would like to ask how to add transition animations when using navController to call pages in jetpack Compose?
    f
    t
    • 3
    • 8
  • d

    Danish Ansari

    04/01/2021, 11:53 AM
    Is it possible? asking just for fun 😅 https://twitter.com/md_is_coding/status/1377588539714543617?s=20
    f
    a
    • 3
    • 3
  • s

    Sergey Y.

    04/01/2021, 12:00 PM
    https://twitter.com/codinginflow/status/1377569980661821441
    😂 21
    😽 2
    😞 1
    a
    a
    +3
    • 6
    • 7
  • s

    Slackbot

    04/01/2021, 12:27 PM
    This message was deleted.
    a
    z
    +2
    • 5
    • 7
  • j

    julioromano

    04/01/2021, 3:34 PM
    Is there a way to tell a
    Row
    to invert the order it lays out its content? (e.g. LTR instead of RTL)
    ✅ 1
    z
    v
    c
    • 4
    • 12
  • n

    Nthily

    04/01/2021, 3:37 PM
    I wrote a start screen, and then used the delay method to launch the main screen, but I found a problem, as long as I write navController.navigate after the delay method, I need to press the return button twice to end the program, but without the delay method only need to press once to end the program, I guess it may be a problem of the delay method, how should I fix it?
    val delayedHandler = Handler()
    delayedHandler.postDelayed({
        navController.navigate("mainPage") {
            popUpTo("welcome") { //delete
                inclusive = true //close stack
            }
        }
    }, 2000)
    s
    • 2
    • 3
  • m

    Muhammad Zaryab Rafique

    04/01/2021, 3:52 PM
    Hi guys
    j
    t
    • 3
    • 2
  • m

    Muhammad Zaryab Rafique

    04/01/2021, 4:13 PM
    Hi Everyone, I wrote code of GPSTracker that giving correct coordinates but it not working first time when location permission dialog appears it work second time when open app agian. Kindly see and tell me solution or how to fix it. I am very thankful.
    g
    b
    c
    • 4
    • 8
  • e

    eschrag

    04/01/2021, 6:01 PM
    I’m trying to figure out how to replicate some of the old drawable state list background color functionality, where the background color changed on press (with no ripple), and really struggling. any resources on how to accomplish this?
    z
    c
    l
    • 4
    • 14
  • a

    Abhishek Dewan

    04/02/2021, 5:25 AM
    Hey guys, is there a way to do something like
    Column(modifier = Modifier.verticalScroll(rememberScrollState()) {
       LazyVerticalGrid()....
    }
    I am trying to make something like but with the entire page being scrollable. Is there a way to do this using the above snippet or would I have to make the grid manually?
    👍 2
    a
    n
    • 3
    • 4
  • s

    Socheat KHAUV

    04/02/2021, 7:19 AM
    anyone know a way to load Font from http url instead of ResourceID ?
    c
    o
    • 3
    • 4
  • l

    Lucien Guimaraes

    04/02/2021, 10:31 AM
    Is there a default padding end/start for AlertDialog ? I was checking my implementation on a small device (3.7" - 480*854 - hdpi) but these padding are missing. As you can see on attached screenshot the alertDialog on the small device, the dialog is taking fullscreen width. Strangely it's working fine on bigger devices. Why so ? I checked on Compose sample and they never customize the modifier parameter of Alertdialog. What is the intended behaviour ? Should we always implement our own start/end padding to avoid this issue or is it a bug from AlertDialog implementation in Compose ?
    ➕ 2
    • 1
    • 2
  • c

    Cyril Find

    04/02/2021, 1:54 PM
    Hi all, I'm trying to implement video trimming similar to this image but wondering about the good way to do the UI part in Compose: I made a prototype with 2
    Slider
    components but they're not very customizable and I can't put one over the other over the "timeline" because only the top-most one is interacting then. I'm thinking I need to implement a custom
    DoubleSlider
    but it seems complicated, any thoughts ? Thanks 🙂
    ➕ 1
    m
    a
    • 3
    • 4
  • n

    Nthily

    04/02/2021, 8:38 PM
    How do I get OutLinedTextField to autofocus? I want the first TextField effect to be displayed as soon as I enter this screen
    ➕ 1
    d
    • 2
    • 3
  • m

    manueldidonna

    04/02/2021, 11:27 PM
    I noticed how the first touch on a scrollable surface triggers the ripple of the clickable item below. That doesn't happen in the view-based ui
    a
    • 2
    • 1
  • t

    therealbluepandabear

    04/03/2021, 1:02 AM
    So who won the jetpack compose challenge? Who gets the Google Phone?
    👍 1
    t
    • 2
    • 2
  • m

    Muhammad Zaryab Rafique

    04/03/2021, 5:05 AM
    Hi Everyone, can anybody know how to refresh the compose function?
    k
    a
    g
    • 4
    • 4
  • t

    Timo Drick

    04/03/2021, 11:49 AM
    Is it possible to compile compose code as KotlinScript? Maybe someone can give me a hint. I think i have to enable the compiler plugin of compose. But i do not know how to do that.
    m
    s
    +3
    • 6
    • 24
  • k

    knthmn

    04/03/2021, 2:18 PM
    This crashes with
    IllegalStateException: Start/end imbalance
    @Composable fun A() = Row { if (true) return }
    It does not happen if I remove the
    if
    or if I use
    return@Row
    a
    j
    p
    • 4
    • 10
  • s

    subashz

    04/03/2021, 4:36 PM
    How to increase the height of the composable after adding aspectRatio to the composable. I have this usecase where you will have square box after some condition, I need to increase the height of that composable.
    t
    • 2
    • 1
  • z

    zsperske

    04/03/2021, 6:51 PM
    Has anyone seen this error? I’m on the latest Android Studio canary, compose version, kotlin version
    z
    d
    • 3
    • 3
  • s

    sashjakk

    04/03/2021, 6:59 PM
    Hey, anyone tried already accompanist-pager?
    c
    • 2
    • 11
  • n

    natario1

    04/03/2021, 7:37 PM
    Side question, how to tell AS to not reformat the whole file every time I hit some
    @Composable
    autocomplete suggestion, adding tons of opinionated newlines and indentation? It's so annoying.
    :google: 3
    t
    • 2
    • 5
  • e

    enighma

    04/03/2021, 10:35 PM
    The documentation has this example if I want to add a state to my component:
    var expanded by remember { mutableStateOf(false) }
    Currently this gives me a compilation issue in beta2. I can write
    var expanded = remember { mutableStateOf(false) }
    But that makes more painful to use. Is this something that has changed, or a bug?
    a
    s
    • 3
    • 3
  • m

    Muhammad Zaryab Rafique

    04/04/2021, 7:37 AM
    Hey Everyone, anybody know how to toggle between dark and light theme in jetpack compose.
    f
    • 2
    • 2
  • a

    allan.conda

    04/04/2021, 8:47 AM
    Trying to add a ComposeView into a Window service for a Foreground Service. The view asks for LifecycleOwner and SavedStateRegistryOwner, and I’m having trouble making it work. Any idea on this? I’m basically trying to draw a ComposeView on top of other apps.
    m
    h
    • 3
    • 11
Powered by Linen
Title
a

allan.conda

04/04/2021, 8:47 AM
Trying to add a ComposeView into a Window service for a Foreground Service. The view asks for LifecycleOwner and SavedStateRegistryOwner, and I’m having trouble making it work. Any idea on this? I’m basically trying to draw a ComposeView on top of other apps.
Untitled.kt
I’m getting this error:
java.lang.IllegalStateException: You can consumeRestoredStateForKey only after super.onCreate of corresponding component
        at androidx.savedstate.SavedStateRegistry.consumeRestoredStateForKey(SavedStateRegistry.java:77)
m

Mark Murphy

04/04/2021, 11:05 AM
See https://gist.github.com/handstandsam/6ecff2f39da72c0b38c07aa80bbb5a2f (as seen in https://jetc.dev/issues/049.html) for an example of a system overlay using Compose UI
😍 1
a

allan.conda

04/04/2021, 11:52 AM
Omg youre CommonsWare. Thanks! I'll try it out.
m

Mark Murphy

04/04/2021, 11:55 AM
I can't take the credit for the gist -- that was @handstandsam! I'm just an implementation of a message bus. 😁
a

allan.conda

04/05/2021, 2:40 PM
It worked! thank you so much
I got a bubble overlay working under a transparent Box so I could move it around. The Box is taking all the touches however so I can’t touch the view behind it. I’m trying to find a solution. ComposeView is final so I can’t override
dispatchTouchEvent
to ignore touches, and I can’t find a Compose way to ignore touches. Any ideas?
m

Mark Murphy

04/06/2021, 12:11 PM
The Box is taking all the touches however so I can’t touch the view behind it
I don't think that is a Compose issue. Do you have a sample app working outside of Compose that is doing what you want?
ComposeView is final so I can’t override 
dispatchTouchEvent
 to ignore touches
AFAIK, that has not been relevant since Android 4.0. AFAIK, you need to look at window flags to provide to the window, such as
FLAG_NOT_TOUCHABLE
or perhaps
FLAG_NOT_TOUCH_MODAL
. And, this is not tied to Compose. I recommend that you get a sample working first without Compose UI, then (and only then) adapt it to Compose.
a

allan.conda

04/06/2021, 12:19 PM
Yep. I’ve been trying those flags,
FLAG_NOT_TOUCHABLE
won’t let me touch my overlay button.
FLAG_NOT_TOUCH_MODAL
is the closest that could work but I cannot move around my compose button without having a fillMaxSize() parent where it could move around. You’re right, I should try to make this work without compose… There’s a bunch of apps that were able to achieve this though (without using the new Bubble API)
h

handstandsam

04/08/2021, 11:29 AM
Glad it worked! 🙂
a

allan.conda

04/23/2021, 5:49 PM
So you were right @commonsware . The window is taking all the input, basically. The bubble implementations I saw wrap the window into the small button and reposition the window itself so it doesn't block stuff behind it. I didn't find a way to modify the window within compose as it's within a ComposeView, so I guess I'd need to handle touch and positioning the old way in this case...
👍🏻 1
View count: 1