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

    KotlinLeaner

    09/20/2022, 2:00 PM
    Hi guys what is recommended way of using
    Spacer
    in jetpack compose?
    Spacer(modifier = Modifier.height(16.dp))
    v/s
    Spacer(modifier = Modifier.preferredHeight(16.dp))
    what is the difference between
    height
    and
    preferredHeight
    ?
    s
    f
    • 3
    • 5
  • s

    Slackbot

    09/20/2022, 4:28 PM
    This message was deleted.
  • b

    Brandon Howard

    09/20/2022, 5:18 PM
    Is there a more standard way of accomplishing this in Compose? (My very React inspired solution for holding a reference to a value across renders)
    data class Ref<T>(var current: T? = null)
    
    @Composable
    fun SomeCmpt() {
      var jobRef = remember { Ref<Job>() }
    
      ...
    }
    c
    s
    • 3
    • 10
  • t

    Travis Griggs

    09/20/2022, 6:28 PM
    Why can I set the
    color
    of
    Text
    , but not of
    ClickableText
    ?
    z
    c
    +2
    • 5
    • 10
  • s

    spierce7

    09/20/2022, 8:11 PM
    I’m curious, has anyone found a better way to maintain View State between screen navigations, like scroll position, besides doing something like state hoisting?
    i
    • 2
    • 3
  • m

    mattinger

    09/20/2022, 9:16 PM
    One thing i’ve noticed after upgrading from compose 1.1.1 to 1.2.1 (along with a kotlin 1.7.10 bump) is that I can no longer do this:
    val screens = listOfScreens.sortedBy {
                stringResource(it.label)
            }
    it complains that i can’t execute the stringResource function outside of composable scope. Instead i have to do this:
    val context = LocalContext.current
            val screens = listOfScreens.sortedBy {
                context.getString(it.label)
            }
    I’m a little confused what has changed between either kotlin or compose that this became a compile error
    m
    m
    • 3
    • 4
  • c

    Colton Idle

    09/21/2022, 6:32 AM
    Did anything significant change in AS Flamingo or Android 13 to improve Live Edit speed? A sample project used to take like 200ms for updates, but now it seems like its sub 50ms (if not less). Really almost feels instant (i know its a tiny project) but even previously on a sample it wasn't this quick. awesome job compose team!
    s
    c
    +2
    • 5
    • 13
  • s

    Slackbot

    09/21/2022, 9:57 AM
    This message was deleted.
  • k

    KotlinLeaner

    09/21/2022, 11:39 AM
    Hi guys I am learning side-effect in my project. I want to know when should I use
    LaunchedEffect
    and
    SideEffect
    in which scenario. I am adding some piece of code using both effect. Please lemme know if I am doing wrong here.
    f
    • 2
    • 12
  • z

    Zoltan Demant

    09/21/2022, 12:23 PM
    Has anyone successfully used
    @Preview
    annotations to generate screenshots for the play store? This was a #showerthought but its been a few hours and I havent been able to pick it apart yet. Seems like an easy approach, as compared to generating all that fake data. Any cons, besides it being very tied to compose (which I dont mind ❤️)?
    l
    a
    a
    • 4
    • 5
  • c

    Chris Fillmore

    09/21/2022, 1:01 PM
    Is there a plan (even a distant one) to support accessibility settings in Compose
    @Preview
    ? (font size, display scale) Thanks
    t
    c
    • 3
    • 5
  • v

    Valentin Gusselnikov

    09/21/2022, 3:44 PM
    Hi! I've noticed that
    Modifier.progressSemantics
    causes recompositions. I've a custom
    ProgressIndicator
    , and if I use
    Modifier.progressSemantics
    Android Studio "Layout inspector" shows thousand recompositions. Is it a bug of "Layout inspector", or it is normal?
    t
    a
    • 3
    • 6
  • s

    Samy Benmeddour

    09/21/2022, 5:22 PM
    Hello! I'm surprised, i noticed a bit late that longClicks are not working with non-touch events :( Does anyone has a workaround to get longClick working with tv remotes or gamepad controllers (based on KeyEvents) ?
  • a

    Alexander Karkossa

    09/21/2022, 8:10 PM
    Hey guys, i need help. I released my new app one week ago. A few days after release, i got multiple issues reporting the same problem. The "comma" is not clickable on the Keyboard on Samsung phones located in germany. I checked the KeyboardType, but i used KeyboardType.Decimal. I will attach a screenshot. System is set to English (Germany). Reproducable with most Samsung phones. Compose Version 1.2.0 Same behaviour with Compose 1.3.0-beta03 There are some known problems on Stackoverflow, but noone has a workaround for compose... https://stackoverflow.com/questions/65184373/comma-doesnt-work-on-samsung-android-keyboard https://stackoverflow.com/questions/72044124/show-comma-instead-of-dot-keyboard
    h
    j
    +2
    • 5
    • 21
  • c

    corneil

    09/21/2022, 8:34 PM
    Comma and Dot may be a Language setting specific problem related to the relevant language. It may be interesting to dig into the Compose code to see how the language settings are applied.
  • s

    Slackbot

    09/21/2022, 11:34 PM
    This message was deleted.
  • j

    Jaime

    09/21/2022, 11:51 PM
    Hello everyone, I have a question in compose is it possible to create something like this (image in the thread), in xml it is a layerList in compose how could I do it
    s
    • 2
    • 1
  • a

    Aaron Waller

    09/22/2022, 2:08 AM
    Why cant I define custom colors in Jetpack Compose?
    Button(
        onClick = { /*TODO*/ },
        colors = ButtonDefaults.buttonColors(backgroundColor = Color(0xF7B500))){
    }
    Is showing me a Grey button but it should be Yellow/Gold
    k
    t
    • 3
    • 2
  • g

    Gal Kohen

    09/22/2022, 8:14 AM
    Hey everyone, we use Appium for automation tests, in the past, we used id for testing, what is the equivalent in compose?
    y
    • 2
    • 4
  • t

    Tolriq

    09/22/2022, 8:51 AM
    Is there a way to properly clip an
    AnimatedVisibility
    ? Clipping passed to the
    AnimatedVisibility
    modifier is not working and the animation runs with a square
    .clip(CircleShape)
    o
    d
    • 3
    • 9
  • o

    oday

    09/22/2022, 9:53 AM
    so I have two composables that I would like to add to the screen, a TopAppBar that stays at the top, and under it another element if I add them sequentially one after the other (without specifying a column for them to sit in), the top bar appears at the top, and the header appears in the center if I specify a colum, the top bar still appears at the top but now the header stops appearing
    Column {
        TopAppBarSearch(
            searchText = searchState.searchText,
            placeholderText = stringResource(id = R.string.search_for_a_city),
            showClearButton = searchState.showClearButton,
            showProgressBar = searchState.showProgressBar,
            matchesFound = searchState.cities.isNotEmpty(),
            onSearchTextChanged = { viewModel.onSearchTextChanged(it) },
            onClearClick = { viewModel.onClearClick() },
            onNavigateBack = { navigateBack() },
            onEmptySearchResults = { NoSearchResults() },
            onSearchResults = {
                Cities(cities = searchState.cities) { city ->
                    viewModel.selectLocation(city)
                    navigateBack()
                }
            }
        )
    
        AnimatedVisibility(
            visible = !searchState.isNetworkError
                    && !searchState.isOtherError
                    && searchState.cities.isEmpty(),
            enter = fadeIn(),
            exit = fadeOut()
        ) {
                MyLocationHeader {
                    viewModel.selectCurrentLocation()
                }
        }
    }
  • m

    miqbaldc

    09/22/2022, 9:59 AM
    Anyone experiences issue when using
    @Preview
    with
    rememberAsyncImagePainter
    inside it, and showing an error instead?
    stacktrace in 🧵
    t
    • 2
    • 2
  • a

    AmrJyniat

    09/22/2022, 1:05 PM
    Try setting
    width = Dimension.fillToConstraints
    to the yellow text
    b
    • 2
    • 1
  • s

    Simona Stojanovic

    09/22/2022, 3:16 PM
    Hi everyone :android-wave: We’re trying to get more input from you all on the way you use the Accompanist Pager for Compose :) Would you be so kind 🌻 to answer any of the following: - What are some of the most important API features that you found in the Accompanist Pager and some you didn’t find so useful? - Are most cases covering single full-page paging with tabs or not? - Have you been using Lazy lists in any way as a replacement, and if so, how? - Related to the above, have you been using Lazy lists to potentially build smaller pages (like carrousels) and was that sufficient? Any feedback is much appreciated, thanks a lot! 🤙
    a
    s
    +3
    • 6
    • 10
  • c

    Chris Fillmore

    09/22/2022, 5:28 PM
    I’m having an issue with loading images via Coil
    AsyncImage
    where
    data
    is a
    File
    , after upgrading to Android 13 (the issue does not repro on Android 12). These images don’t load anymore. Images which load from URI strings still load correctly. Anyone encountered something like this? Thanks in advance. Tested Coil v 2.2.0 and 2.2.1
    c
    • 2
    • 14
  • n

    nuhkoca

    09/22/2022, 8:37 PM
    Hello, how can I use
    rememberSaveable
    for
    Animatable
    ?
    val pathPortion = rememberSaveable { Animatable(initialValue = 0f) }
    l
    • 2
    • 2
  • c

    Colton Idle

    09/23/2022, 3:01 AM
    Compose Version 1.3.0-beta03 released yesterday. Some interesting things from my point of view • Add options to customize line breaking in Text. (I86907) HELL YEAH • `BringIntoViewResponder`s are now able to get the most up-to-date bounds of a request while processing it. (not sure what this is but seems helpful) • Introduce support for spacings between items to experimental
    Staggered Grid
    (I10b82) • Introduce content padding to experimental
    Staggered Grid
    (I342ea) • Added
    Modifier.withConsumedWindowInsets()
    to get consumed
    WindowInsets
    for use outside
    windowInsetsPadding
    . • Added
    MutableWindowInsets
    to allow easily changing
    WindowInsets
    without recomposition. • Fix fling animation cancellation issue (i wonder if this fixes flinging bottom sheet modals getting stuck when fully open) • Add a Pull-To-Refresh component to Compose (I29168) OOOH What is this!? Another thing from accompanist that can die? (commit message: Migrates Accompanist's SwipeToRefresh to Compose with major changes.) so yes. it can die it seems. • Behavior Breaking Changes (next two points) • The parameter to
    remember
    and
    rememberCoroutineScope
    where changed to be
    crossinline
    . This will report an error for early returns instead of allowing an early return which will cause a later internal error to be reported. • This change can potentially lead to new compiler errors to be reported requiring non-local returns to be removed from the lambdas passed to these functions. (Ibea62) • AndroidX Activity's
    BackHandler
    API now works within a
    Dialog
    composable. (I35342) OH YEAH M3: •
    ExposedDropdownMenuDefaults
    now exposes a padding value for menu items. (I34ee1) ⚠️ Looks like coil and latest compose don't play well together. https://github.com/coil-kt/coil/issues/1473
  • u

    肖志康

    09/23/2022, 4:16 AM
    Hello everyone, I'm using
    TextField
    with some
    annotations
    in the
    TextFieldValue
    , but in the
    onValueChange
    callback all the
    annotations
    are gone. How can I restore them?
  • s

    Saketh

    09/23/2022, 8:13 AM
    Hello folks, I'm working with a constraint layout where I'm using a guideline but I can't scroll down even though I have added the vertical scroll; if I remove the guide line everything is working fine as expected. Can anyone help me out?
  • a

    AmrJyniat

    09/23/2022, 9:25 AM
    Do you guys represent everything in the UI as a state? let's say I want to show a dialog or request permission, should I add these actions as state or it seems overwhelming?
Powered by Linen
Title
a

AmrJyniat

09/23/2022, 9:25 AM
Do you guys represent everything in the UI as a state? let's say I want to show a dialog or request permission, should I add these actions as state or it seems overwhelming?
View count: 3