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

    brabo-hi

    01/28/2022, 11:22 PM
    Hi all, i have a composable
    composable("profile/{userId}"){}
    how to get the
    startDestination
    to be something like
    NavHost(startDestination = "profile/42") {}
    instead of having to navigate like
    navController.navigate("profile/42")
    i
    c
    • 3
    • 8
  • c

    Colton Idle

    01/29/2022, 5:24 AM
    Next to the @Preview annotation there used to be a gear icon in the gutter so that you could fiddle with different preview args. Did that go away intentionally?
    👍 1
    a
    t
    c
    • 4
    • 9
  • t

    theapache64

    01/29/2022, 9:35 AM
    Keyboard type changes very quickly during focus request looks fixed. But i guess its not included in the recent compose-ui release(1.2.0-alpha02). How can i test the fix? Do we have a snapshot build?
    ✅ 1
    c
    z
    • 3
    • 4
  • j

    jasu

    01/29/2022, 10:33 AM
    Why my keyboard seems janky while moving focus from one textfiled to another, any idea?
    Screenrecorder-2022-01-29-16-00-02-129.mp4
    o
    c
    • 3
    • 3
  • t

    theapache64

    01/29/2022, 1:13 PM
    How do I disable the bubble? 🤔 Usecase: I’ve a single digit OTP input field and it doesn’t need that
    :plus1: 4
    b
    c
    +2
    • 5
    • 11
  • a

    adjpd

    01/29/2022, 4:18 PM
    Hi, I'm using
    rememberSaveable {}
    on a custom class that implements
    Parcelable
    . This saves and restores the object on screen rotation perfectly. All the warning messages, however, tell me that this should not work. Can you help me understand the warning messages? And help me understand if I'm doing something wrong? Code and warnings in 🧵
    p
    t
    • 3
    • 8
  • s

    SrSouza

    01/29/2022, 6:55 PM
    There is any documentation that contains all Local Composition provided by Compose Activity ? like LocalContext, LocalLifecycleOwner, etc.
    :plus1: 1
    t
    z
    • 3
    • 3
  • c

    Colton Idle

    01/30/2022, 12:49 AM
    Trying to add compose to a project. I'm 'somehow adding compose 1.0.5 even though I'm trying to use 1.2.0-alpha02 When I do ./gradlew app:dependencies I see
    kotlin-extension - Configuration for Compose related kotlin compiler extension
    \--- androidx.compose.compiler:compiler:1.0.5
    Any idea what that is?
    • 1
    • 1
  • s

    Saiedmomen

    01/30/2022, 10:14 AM
    Is Shared element transition included in the 1.2.0-alpha? Is there an issue tracking this feature?
    d
    h
    • 3
    • 2
  • j

    jasu

    01/30/2022, 12:20 PM
    Selection toolbar disappears in BasicTextField when
    Select all
    is selected, what to do?
    • 1
    • 1
  • j

    Jason Ankers

    01/30/2022, 2:56 PM
    Is it possible to wait for effects down a composable hierarchy to run before rendering the UI? I.e. ComposableA enters the composition, runs some effects, calls a child composable which also runs effects. I would like to prevent rendering any UI down this hierarchy until both effects have run, is this possible? In React I think this would be achievable with useLayoutEffect
    a
    l
    • 3
    • 28
  • f

    Florian Walther (live streaming)

    01/30/2022, 3:49 PM
    Why is my
    Switch
    outside of the
    Row
    even though the code is inside the block?
    a
    a
    +2
    • 5
    • 11
  • k

    Kyant

    01/30/2022, 3:54 PM
    How to fix the position of composables even if a composable changes size? 🤔 Should I customize a layout?
    a
    • 2
    • 9
  • m

    Marcin Wisniowski

    01/30/2022, 4:45 PM
    Is there a better way of previewing all my composables in light and dark mode, without having to duplicate every @Preview function?
    f
    a
    c
    • 4
    • 7
  • z

    Zun

    01/30/2022, 6:23 PM
    I want my ViewModel be the source of truth for whatever the user entered in a text field. Would this be the correct way or is there a better approach. See thread
    a
    a
    • 3
    • 7
  • a

    adjpd

    01/30/2022, 7:38 PM
    Is there a way to check which
    Composable
    is needlessly being recomposed? I want to see if a
    Text
    is recomposed for example.
    s
    j
    c
    • 4
    • 4
  • m

    Marcin Wisniowski

    01/30/2022, 8:08 PM
    How can I set a preview placeholder for a Coil image? It lacks an alternative to
    tools:src
    . The Accompanist version had a
    previewPlaceholder
    . But after Compose support moved to the Coil library proper, it was removed. Are there any solutions?
    s
    • 2
    • 8
  • s

    Shakil Karim

    01/31/2022, 6:36 AM
    Hi, i was looking at JetNews source code, Can someone please help me understand the need of key here, is there any downside if don't use it? https://github.com/android/compose-samples/blob/84dc6417dfbd6408f498d71afcc1272087[…]ws/app/src/main/java/com/example/jetnews/ui/home/HomeScreens.kt
    j
    a
    • 3
    • 7
  • j

    Jonas Frid

    01/31/2022, 7:44 AM
    Hello! I need to have line charts in my app that is almost entirely built with Compose. I was looking at MPAndroidChart at first, but I need a feature that I could not find was available. All values have defined ranges with a color so the color of the line needs to change in a smooth way as the line moves through those ranges. Any suggestions about a good charting component that this is easy to do?
    t
    • 2
    • 2
  • u

    Utkarsh Tiwari

    01/31/2022, 8:30 AM
    Hi, Is there any way to enable this cursor handle in OutlinedTextField to allow convenient dragging of cursor across characters? Two cursor handle seem to appear on long press but I want to single handle for short tap and drag.
    z
    c
    • 3
    • 7
  • a

    Anastasia Rozovskaya

    01/31/2022, 10:25 AM
    Hello! Is there a way to provide 3d party context to Composable Preview? Details in the thread.
    z
    • 2
    • 14
  • r

    Rick Regan

    01/31/2022, 4:44 PM
    State and Jetpack Compose says "While remember helps you retain state across recompositions, the state is not retained across configuration changes. For this, you must use rememberSaveable." On this channel, we've said that setting `android:configChanges`(as listed here) to handle the configuration changes would allow us to use plain old
    remember
    . Is it better to do the former or the latter?
    c
    a
    r
    • 4
    • 4
  • n

    Nick

    01/31/2022, 4:54 PM
    <androidx.compose.ui.platform.ComposeView
                android:id="@+id/myComposeView"
                android:layout_width="10dp"
                android:layout_height="10dp"
    ---->       tools:composableName=""        <------
                />
    What is
    composableName
    used for?
    • 1
    • 2
  • m

    myanmarking

    01/31/2022, 5:18 PM
    why can i filter text in a TextField with keyboardType = Number, but not with keyboardType = Text. I doesn’t make sense
    • 1
    • 2
  • b

    brabo-hi

    01/31/2022, 6:36 PM
    Hi all, what is the best way to animate
    show/hide
    of keyboard ?
    val keyboardController = LocalSoftwareKeyboardController.current
    keyboardController?.hide() // How to animate the visibility ?
    z
    c
    • 3
    • 4
  • r

    rocketraman

    01/31/2022, 6:41 PM
    Reading this post on Reddit, and related stuff, about destructuring declarations for Compose state: https://www.reddit.com/r/androiddev/comments/rqdv5g/there_are_three_ways_to_declare_a_mutablestate/. References: • Twitter thread where @Zach Klippenstein (he/him) [MOD] says "it's a footgun": https://twitter.com/zachklipp/status/1475913455857111040?s=20 • Same Twitter thread where @Leland Richardson [G] says "I think there might be a just-as-compelling argument that the other forms are actually more foot-gun-like than this?": https://twitter.com/Louis_CAD/status/1476180047476232192 • https://issuetracker.google.com/issues/212452424 Discuss 🙂 To start, I personally like assigning the value to a
    val
    rather than using a
    var
    and delegates. But I'm trying to understand the Redditor's examples. Why doesn't the Draggable example work (assuming it doesn't, I haven't tried it)? Their explanation:
    When Jetpack invokes the detectDragGestures callback, it's the same lambda instance. That means we never get the new values of offsetX and offsetY.
    But shouldn't
    DraggableZone
    and
    Draggable
    recompose when the offset changes, thus getting new values of
    offsetX
    and
    offsetY
    in
    detectDragGestures
    ?
    y
    a
    +2
    • 5
    • 10
  • b

    blakelee

    01/31/2022, 8:51 PM
    Is there a way to listen to when the soft keyboard is hidden? I'm trying to use a back handler but when a user has a text field selected it closes the keyboard, then pressing back again doesn't seem to get triggered with the handler
    z
    • 2
    • 1
  • a

    Andy Himberger

    01/31/2022, 9:05 PM
    I'm seeing a timing issue with staticCompositionLocal, if I update the value of my local 2 times quickly, not all places that refer to the local always get updated. I have been trying to produce a demo project but I haven't been able to hit the problem in isolation yet, the place I've seen that doesn't update has a lazy list with a bunch of images loading in it so its the slowest thing to recompose. What I found interesting is if I use a non-static compositionLocal then it works fine. The local i'm defining is used to define window size class/foldable information which gets updated 2 times after rotation / activity recreate due to how the androidx.window async API works on Samsung devices. (I mentioned this here a couple weeks ago thinking that just referring to state wasn't refreshing, but it seems to be actually the static composition local not the state). There was other strange behavior I saw falling out of this, if I have a state value that is updated after a flow collect inside LaunchedEffect, when the bug happens one of the places on screen does not have the launchedeffect value. All fallout of not everything being updated..
    z
    c
    a
    • 4
    • 6
  • l

    Landry Norris

    01/31/2022, 10:16 PM
    I noticed that the latest beta of compose-jb seems to support ios UIKit. Can we expect to see this in the 1.1.0 release, or will it be an experimental/beta-only feature like Android’s Compose was?
    👀 3
    c
    • 2
    • 1
  • d

    dimsuz

    02/01/2022, 12:10 AM
    I'm not sure if the behaviour I'm seeing is the bug in the intrinsic measurements, but it's certainly something that had me confused for several hours. tl;dr: adding an
    Icon
    results in Row with intrinsic height having a half-cut-out text. Sample in the thread.
    a
    • 2
    • 5
Powered by Linen
Title
d

dimsuz

02/01/2022, 12:10 AM
I'm not sure if the behaviour I'm seeing is the bug in the intrinsic measurements, but it's certainly something that had me confused for several hours. tl;dr: adding an
Icon
results in Row with intrinsic height having a half-cut-out text. Sample in the thread.
Row(modifier = Modifier.width(180.dp).height(IntrinsicSize.Min)) {
  Column(
    modifier = Modifier.background(Color.Gray)
      .weight(2/3f)
      .fillMaxHeight()
  ) {
    Icon(imageVector = Icons.Default.Check, contentDescription = null)
    Text(text = "hello world and foo bar")
  }
  Column(
    modifier = Modifier.background(Color.Green)
      .weight(1/3f)
      .fillMaxHeight()
  ) {
    Icon(imageVector = Icons.Default.Check, contentDescription = null)
    Text(text = "hello")
  }
}
result is this:
but if I add a
Modifier.size(24.dp)
to `Icon`s (or even remove them), then calculations seem to start to work:
If I have the top
Row
fill max width and no modifiers on icons, then text even won't show up at all. only icons. It was very confusing initially. Is this the expected behavior?
a

Albert Chang

02/01/2022, 2:21 AM
https://issuetracker.google.com/issues/198206454
🙏 1
View count: 2