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

    kevindmoore

    07/26/2021, 2:10 AM
    This is with an example app from the compose samples
    c
    a
    3 replies · 3 participants
  • m

    ms

    07/26/2021, 3:12 AM
    When using
    imePadding()
    it doesn't animate upon keyboard visible, but if I use
    navigationBarsWithImePadding()
    it animates. I only need to animate ime height excluding navBars height. @cb any inputs?
    c
    2 replies · 2 participants
  • r

    Richard Graham

    07/26/2021, 3:45 AM
    Hi there. Has anyone had trouble with using Compose in an existing screen? I have an Composable button that handles its own text. When the text is updated the whole element flashes on screen and appears to enter on the left or right side depending on whether the text is expanding or shrinking. I've tried adding
    android:animateLayoutChanges="false"
    to the xml file and have played around with
    AnimatedContent()
    and
    .animateContentSize()
    to no avail. I'm assuming it has something to do with the whole element being updated for some reason but am out of ideas on how to fix it, any thoughts?
    1 reply · 1 participant
  • c

    Colton Idle

    07/26/2021, 4:42 AM
    Using compose navigation and a single activity app, I have a composable
    SignInScreen
    that should not follow the typical "back press = popBackStack". When on the SignInScreen, the MainScreen is in the stack, but in this case I want the app to just close. Where is the more appropriate place to override this? In the
    SignInScreen
    composable itself? Or on the activity level?
    y
    11 replies · 2 participants
  • a

    Abhishek Dewan

    07/26/2021, 7:34 AM
    Does anyone know of a good way (example) of taking a landscape image and rotating it to fit the screen in portrait mode. I am trying to use the .rotate modifier but I've noticed that it messes with the images size for some reason
    z
    5 replies · 2 participants
  • s

    StefMa

    07/26/2021, 8:00 AM
    Hey, i have an
    DialogFragment
    which creates an
    AlertDialog
    with the
    MaterialAlertDialogBuilder
    . The customView I created for the
    AlertDialog
    is created with a
    ComposeView
    . Inside this View I create a
    OutlinedTextField
    . This "works" and the correct view show up. But unfortunately, the Keyboard does not show up on click on the
    TextField
    😱 I tried it already with the
    FocusRequester
    , and with a different
    AlertDialog
    (from androidx instead of material package). No luck. I moved the ComposeView into a "normal"
    Fragment
    . There, everything works as expected. So I guess it is a
    DialogFragment
    related issue... Can someone help me out here? Is this a bug? 🤔
    c
    2 replies · 2 participants
  • r

    Radu - Ionut Kurta

    07/26/2021, 8:33 AM
    Hello, I'm curios how to correctly use buttons so that they ripple animation plays out properly: Let's say I use a navigation icon to navigate to the profile screen of my application, once I tap on it the ripple effect starts and the navigation host changes the screen to the profile composable also the profile icon will now be replaced with the arrow back icon, I'm guessing because of re-composition the ripple animation never plays out and there is a very hard visual swap between icons and screens, this is also visible if you would have a lazy list with items and tapping on one item would remove it from the list, the tap ripple animation would never play out. My workaround was to just wrap all on click actions in an animateAfter() function that delays the actual on click by a few milliseconds to give the ripple animation time to play out. But it doesn't quite feel right doing this. My question is is there a correct way to do this? is this a bug? Should the on click action of the composable happen automatically at the end of the animation or somehow trigger across re-compositions? Thanks
    n
    6 replies · 2 participants
  • m

    Mohamed Ibrahim

    07/26/2021, 8:38 AM
    is there any tutorial or learning guide for Jetpack compose for desktop
    a
    m
    +1
    3 replies · 4 participants
  • a

    allan.conda

    07/26/2021, 10:40 AM
    Trying out compose-navigation dialogs. What would be the correct way to navigate from the dialog? Currently navigating from it dismisses the dialog and I can’t go back, unless it navigates to another dialog. I’m using these dialog destinations as Full-screen dialogs, and some screens can be navigated to from this dialog and also from other
    composable
    destinations. I think the compose navigation behavior makes sense. I’m not sure what’s the right way to achieve the requirement, or whether I’m going against the navigation principles.
    i
    14 replies · 2 participants
  • m

    Mjahangiry75

    07/26/2021, 12:18 PM
    Stuck with a brand new weird problem after updating android studio to
    canary 4
    , If I put 13 of
    composables
    inside
    NavHost
    app will crash, error in thread
    a
    2 replies · 2 participants
  • r

    rsktash

    07/26/2021, 12:36 PM
    Hi, why rememberModalBottomSheetState ’s parameter confirmStateChange is called only when sheet is being hidden? When state changes to Expanded it’s not triggered
    m
    3 replies · 2 participants
  • n

    nitrog42

    07/26/2021, 12:58 PM
    be careful using swipable and bottomsheet progress state, as it seems this bug has resurfaced again
    r
    2 replies · 2 participants
  • y

    yousefa2

    07/26/2021, 2:09 PM
    Hey everyone! .. I am trying to a build a server-driven UI which supports declaring the layout at run-time, from the server, instead of at compile-time. Usually at compile-time I would use
    Row
    ,
    Column
    or
    Box
    depending on what I want. You get additional modifiers based on the scope you are in..i.e
    BoxScope.Modifier.matchsParentSize()
    ,
    RowScope.Modifier.weight
    ..etc. I am looking into a way to get these values from the server. Since I don’t know which layout will be rendering at run-time.. I can’t have a scope. I have looked into something like
    fun MyCustomLayout(someLayoutEnum: LayoutTypeEnum, content: @Composable () -> Unit) {
    // do some work here
    }
    Which works to define the layout at run-time but you would still be stuck not knowing the scope and not being able to use
    RowScope.Modifier.weight
    for example. What I am going with right now is copying the Jetpack compose team logic of using a MeasurePolicy + Layout, which is either internal or private, and modifying it to accept a list of modifiers for each child.
    val measurePolicy = rowMeasurePolicy(horizontalArrangement,verticalAlignment, modifiers) // This could be columnMeasurePolicy or boxMeasurePolicy
        Layout(
            content = { content() },
            measurePolicy = measurePolicy,
            modifier = modifier
        )
    My question is, does anyone know a better way of doing this?
    c
    3 replies · 2 participants
  • i

    iamthevoid

    07/26/2021, 2:33 PM
    Hi, could you to explain me why am i not getting the result, what want to get. Code of
    BindScopeWithComposable
    in [Thread].
    BindScopeWithComposable
    (in my opinion) should remember result of
    provideComponent
    lambda between compositions even if i go to the next screen and back.
    BindScopeWithComposable's
    used in the root of Compose navigation graph [Thread]. When i interact with one screen wrapped in
    BindScopeWithComposable
    then
    component
    instance stay the same. But when i go to the next screen and back it is recomposing and new instance of
    component
    now used.
    i
    4 replies · 2 participants
  • e

    eygraber

    07/26/2021, 5:24 PM
    I'm about to get started on moving several large projects to compose, and I want to make sure that the architecture I planned on using would work well performance-wise. <tl;dr> I'm using a
    Flow<SomeState>
    with
    collectAsState
    instead of multiple
    MutableState
    and will rely on function skipping if the discrete fields in
    SomeState
    haven't changed (
    SomeState
    will be immutable). <\tl;dr> (longer description in thread)
    z
    a
    +1
    12 replies · 4 participants
  • d

    dimsuz

    07/26/2021, 5:29 PM
    I'm having this issue with autocompletion of composable parameters not working for quite some time. Arctic Fox RC1 has it too. Here you can see it failing to find
    horizontalAlignment
    . Does anyone know if this is fixed in Canary or ETA on the fix? It's a bit cumbersome to have to jump to compose sources when I forget these parameters...
    ➕ 4
    a
    2 replies · 2 participants
  • c

    Colton Idle

    07/26/2021, 6:20 PM
    Is InsetAwareTopAppBar no longer needed? I see it's gone here, but didn't noticed it in release notes. https://github.com/google/accompanist/blob/main/sample/src/main/java/com/google/accompanist/sample/insets/EdgeToEdgeLazyColumn.kt
    c
    2 replies · 2 participants
  • s

    Shakil Karim

    07/26/2021, 6:48 PM
    Hi, is there an easy way to handle autofocus in TextField, I'm using HorizontalPager from Accompanist, I want to autofocus a TextField when Visible. But when I use FocusRequester() it's causing Wired behaviors like it also creates focus to the Next Composable's TextField
    1 reply · 1 participant
  • c

    Chris Johnson

    07/26/2021, 8:14 PM
    Are there any samples for detecting keyboard visibility? I've looked around and can't find any outside of
    LocalView.current.rootWindowInsets?.isVisible(WindowInsets.Type.ime())
    . But that's for api 30+... I've tried to use
    accompanist's insets
    api to see if there's insets (for the keyboard) but to no success.
    b
    c
    9 replies · 3 participants
  • l

    Landry Norris

    07/26/2021, 9:45 PM
    I'm currently experimenting with using a SharedFlow in my Repository object, and using Compose's collectAsState() function. I noticed that emitting values doesn't update my composable. I ran a debugger with a breakpoint both on the emit line and on the internals of collectAsState. I can see that
    collect { value = it }
    inside of collectAsState() does get called, and 'it' has the correct value, but the UI does not change. The UI did properly respond when I used LiveData and observeAsState(), but I am wanting to switch to Flows.
    z
    y
    18 replies · 3 participants
  • k

    Kefas

    07/27/2021, 2:08 AM
    How to scroll a lazy column by 100 px every 1 second? If I use this code, the
    animateScrollBy
    can be cancelled if I scroll the lazy column at the same time, and then the entire LaunchedEffect will be cancelled.
    val scrollState = rememberLazyListState()
    
    LaunchedEffect(Unit) {
        while (true) {
            delay(1000L)
            scrollState.animateScrollBy(100f)
        }
    }
    l
    a
    +1
    23 replies · 4 participants
  • s

    Sudhir Singh Khanger

    07/27/2021, 3:43 AM
    Are there callbacks for states in a Composable's life cycle similar to View system's?
    z
    c
    +1
    3 replies · 4 participants
  • c

    Colton Idle

    07/27/2021, 5:14 AM
    I'm using accompanist pager for a horizontal pager, and I want to programatically move to the next page. I tried this (see what the button does onclick)
    Column() {
        val pagerState = rememberPagerState(pageCount = 10)
    
        HorizontalPager(state = pagerState) { page ->
            Text(text = "Page: $page", modifier = Modifier.fillMaxWidth())
        }
    
        Button(onClick = { pagerState.animateScrollToPage(pagerState.currentPage + 1) }) {
            Text(text = "Test")
        }
    }
    But I get an error of
    Suspend function 'animateScrollToPage' should be called only from a coroutine or another suspend function
    I thought it was okay to have an event like this in an onClick event since it's not happening on every recomposition?
    k
    a
    +2
    9 replies · 5 participants
  • j

    Jason Roberts

    07/27/2021, 5:17 AM
    Hi, Do jetpack compose trustworthy for business applications? And can we publish an application written with Jetpack compose on Google Play?
    c
    o
    17 replies · 3 participants
  • c

    Colton Idle

    07/27/2021, 5:40 AM
    If I'm in a pure compose app (no fragments), what Activity should I be extending and which artifacts can I remove from my app? I could have sworn that Ian said that once I go full compose I can remove appcompat libs entirely? (but my slack search is failing me)
    h
    a
    +2
    8 replies · 5 participants
  • n

    Nathan Castlehow

    07/27/2021, 6:40 AM
    Hey hey, any super duper compose testers out that could answer a couple questions for me? :) I want to do a quick smoke test where I open particular routes in the app. Similar to jetsnack https://github.com/android/compose-samples/blob/5f250deb3534a6488e45c72b1d101665c5ba0de4/Jetsnack/app/src/androidTest/java/com/example/jetsnack/AppTest.kt Qns in thread
    4 replies · 1 participant
  • l

    Luka

    07/27/2021, 8:13 AM
    Hi. Can you help me to remove start padding from buttons text
    i
    t
    +1
    11 replies · 4 participants
  • j

    Jeff

    07/27/2021, 8:36 AM
    Hi. How do you shift the contents of the screen to the right when the drawer is opened?
    a
    n
    5 replies · 3 participants
  • g

    Geert

    07/27/2021, 8:36 AM
    What does the .then function on a modifier? What is the difference between
    modifier = Modifier
        .then(Modifier.padding(it))
        .then(Modifier.fillMaxSize())
    and
    modifier = Modifier.padding(it).fillMaxSize()
    i
    y
    +1
    3 replies · 4 participants
  • a

    allan.conda

    07/27/2021, 8:55 AM
    https://developer.android.com/jetpack/compose/lists#item-keys Is it preferable to always provide stable keys when available, or are there downsides to using it?
    h
    c
    +3
    10 replies · 6 participants
Powered by Linen
Title
a

allan.conda

07/27/2021, 8:55 AM
https://developer.android.com/jetpack/compose/lists#item-keys Is it preferable to always provide stable keys when available, or are there downsides to using it?
h

Halil Ozercan

07/27/2021, 9:01 AM
I'd say there is really no downside to using key when available. To understand it better I'd recommend checking this thread out. Key concept is very similar in React and Jetpack Compose.
a

allan.conda

07/27/2021, 9:05 AM
I see. Thank you, I’ll check it out
c

cb

07/27/2021, 9:05 AM
Yes, it’s preferable to always provide a key
h

hfhbd

07/27/2021, 9:10 AM
If it is preferable, why does compose do not require them, like SwiftUI with Identifiable?
a

allan.conda

07/27/2021, 9:12 AM
I just discovered it, actually, I’ve never used it in my LazyColumn. I just saw it recently in the changelog and it’s about adding the support for the Paging Items.
c

Colton Idle

07/27/2021, 2:40 PM
Such a great thread @Halil Ozercan 💯
c

cb

07/28/2021, 7:09 AM
Keys were a late addition to the LazyList DSL so I don’t believe there was a way to make them mandatory at the time. @Andrey Kulikov
a

Andrey Kulikov

07/28/2021, 10:21 AM
there are some limitations with keys - the value you provide should be saveable into a Bundle, plus keys should be unique between all the elements in the list. when you don’t provide a key then indexes are used as keys internally
👍 1
c

Colton Idle

07/28/2021, 2:04 PM
Indexes as a fallback makes sense. A lint rule for this would be great I think though.
Filed a FR for a lint rule: https://issuetracker.google.com/issues/194822807
View count: 5