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

    Nicolai

    12/14/2022, 9:42 AM
    Hi 👋 , I hope one of you can be of help to me. I have a LazyColumn that gets populated with different sections that contains a LazyRow. Inside that LazyRow I would like to track when a user has been viewing a given element for more than 2 seconds. This works fine By getting the firstVisibleItemIndex
    val state = rememberLazyListState()
    val visibleIndex: Int by remember {
        derivedStateOf {
            state.firstVisibleItemIndex
        }
    }
    LazyRow that takes the state
    LazyRow(
        state = state
    )..... bla bla
    And then a LaunchedEffect on the visibleIndex
    LaunchedEffect(visibleIndex) {
        delay(2000)
        onMetricViewed(metrics[visibleIndex], visibleIndex)
    }
    My problem now is that this also runs on the second element in the LazyColumn which is far from visible (maybe around 5%). I've tried with calculating the visibility of items but couldn't come up with something that worked as I wanted it to. How can I make sure that
    onMetricViewed(metrics[visibleIndex], visibleIndex)
    is only called if I can actually see the full height of the element in the LazyRow? 🤔
    m
    • 2
    • 6
  • p

    Pablo

    12/14/2022, 12:46 PM
    I need to create a Dialog with wrapcontentheight in the modifier but seems that Dialog doesn't accept a modifier. Any help about how to solve this? Thank you
    a
    • 2
    • 12
  • o

    oday

    12/14/2022, 2:05 PM
    why is not using the material scaffold padding parameter such a big deal? warranting a need for and Error in the code and I have to suppress it ?
    @SuppressLint("UnusedMaterialScaffoldPaddingParameter")
    s
    m
    • 3
    • 3
  • c

    CLOVIS

    12/14/2022, 2:24 PM
    I seem to remember there were a few weird things with inline
    @Composable
    functions, but I can't find where it's documented. Does anyone know?
    z
    • 2
    • 1
  • j

    Jhonatan Sabadi

    12/14/2022, 2:36 PM
    Does anyone knows why i’m getting this white screen? — Using Scaffold at top level
    Gravação de Tela 2022-12-14 às 11.35.49.mov
    k
    c
    • 3
    • 6
  • c

    Csaba Szugyiczki

    12/14/2022, 2:51 PM
    Slider accessibility I cannot find a way to define what TalkBack reads when the Slider value is changed. In my example my slider can have 3 values 0, 1, 2 which then mapped to Walking Speed values: Slow, Medium and Fast respectively. TalkBack reading the percent values of the thumb is not very helpful in this case. Is it possible to override the value read on Slider value change without ruining the functionality of the Slider? (being able to change the value by swiping up or down and by double tap-and-hold then sliding left and right is the basic way a Slider can be used with TalkBack, I do not want to loose this)
    b
    • 2
    • 14
  • s

    Stylianos Gakis

    12/14/2022, 3:56 PM
    What’s the easiest way to provide a spring() spec to an animation, but with an initial delay before it starts? For a tween there’s a
    delayMillis
    which makes this convenient. From what I understand this isn’t the case for the spring one since you want to maintain momentum from potential earlier animations or something like that, is this the case? Now I’m thinking of doing something like
    val animatableProgress = remember { Animatable(0f) }
    LaunchedEffect(Unit) {
        delay(300)
        animatableProgress.animateTo(1f, spring())
    }
    // use animatableProgress
    to use this exact thing, but I feel like I may be missing some API which makes this simpler for me.
    a
    d
    • 3
    • 8
  • l

    luke_c

    12/14/2022, 4:26 PM
    Can you trust the layout inspector recomposition count on a debug build, or should you always be running in release mode?
    f
    c
    • 3
    • 2
  • m

    mattinger

    12/14/2022, 6:12 PM
    So i’m trying to replicate the maxHeightInLinesModifier from compose 1.4 so that it can work with existing versions. I’m having some trouble with the embedded calculations. For whatever reason, it things the paragraph with a single line is 59px tall, and that the paragraph with 2 lines is 111px tall. I would have expected the 2 line paragraph to be at least twice as tall (118px) plus some additional for the line height on the text style. Not sure what I might be missing here.
    @Composable
    @Preview
    fun TestParagraph() {
        val density = LocalDensity.current
        val fontFamilyResolver = LocalFontFamilyResolver.current
        val placeholderText = "H".repeat(10)
    
        val paragraph1 = Paragraph(
            text = placeholderText,
            style = MaterialTheme.typography.body1,
            spanStyles = listOf(),
            maxLines = 1,
            ellipsis = false,
            density = density,
            fontFamilyResolver = fontFamilyResolver,
            constraints = Constraints()
        )
    
        val paragraph2 = Paragraph(
            text = (1.. 2).map { placeholderText }.joinToString("\n"),
            style = MaterialTheme.typography.body1,
            spanStyles = listOf(),
            maxLines = 2,
            ellipsis = false,
            density = density,
            fontFamilyResolver = fontFamilyResolver,
            constraints = Constraints()
        )
    
        val height1 = paragraph1.height
        val height2 = paragraph2.height
    
        Column {
            Text(text = "${height1}")
            Text(text = "${height2}")
        }
    }
    k
    a
    • 3
    • 10
  • j

    james

    12/15/2022, 12:17 AM
    is there a way to observe if an IME animation (either hiding or showing) is currently in progress? we have some code which has a slight delay after calling keyboard
    hide()
    before doing the next thing.. the UX feels nicer than without the delay, but the delay itself feels flimsy — in fact we probably need a condition that says we don’t have a delay on older API levels which don’t animate the IME at all. it’d be cool if there was some kind of
    isImeAnimating
    state I could watch for this purpose, or something I could use to create a derived state to produce my own
    isImeAnimating
    , but I can’t think of anything immediately and a quick search hasn’t turned anything up
    d
    a
    • 3
    • 5
  • p

    pablisco

    12/15/2022, 12:29 AM
    I’m really curious about this, what do you folks think? 🙏
    p
    l
    +4
    • 7
    • 19
  • u

    ursus

    12/15/2022, 12:46 AM
    Premature optimizer question:
    @Composable
    private fun VerticalSpacer(size: Dp) {
        Spacer(modifier = Modifier.height(size))
    }
    Does creating helpers like this add some overhead?
    l
    s
    • 3
    • 3
  • c

    Colton Idle

    12/15/2022, 3:32 AM
    Maybe a shot in the dark, but maybe Ian (or someone from Firebase perf team lurking around). Any chance that we get perf stuff for compose destinations like we get for activities and fragments?
  • j

    Jaime

    12/15/2022, 4:19 AM
    hello everyone I have a crash reported in firebase, but I don’t have much more than the stacktrace I send it in case someone else has happened to it
    i
    c
    • 3
    • 5
  • z

    zt

    12/15/2022, 5:07 AM
    How would I go about creating a composable that has a collapsed form, showing minimal content and a fully expanded form which shows everything. I'm trying to copy how the miniplayer/player is in YouTube. I want it so the components move and resize as its going to a different state. Is that possible in compose?
    r
    m
    c
    • 4
    • 14
  • y

    yogaboy

    12/15/2022, 11:24 AM
    Hi, I have interesting issue 😄 code is
    Scaffold() {paddingValues ->
            Column(
                modifier = Modifier
                    .fillMaxSize()
                    .padding(bottom  = paddingValues.calculateBottomPadding())
    and screen in bottom on old navigation looks like …
  • y

    yogaboy

    12/15/2022, 11:25 AM
    I have to say that I set <item name=“android:navigationBarColor”>@android:color/transparent</item>
  • y

    yogaboy

    12/15/2022, 11:26 AM
    Does anyone know how to fix it? 🙏🏻
    • 1
    • 1
  • j

    jasu

    12/15/2022, 12:18 PM
    I’m using compose navigation in the app I wanted to know, how do I navigate to a destination which is not in my graph? ex: I have a feature F1 whose navigation graph is G1, from within one of the destinations of G1 I want to navigate to another graph G2 which is not part of G1 app/F1 G1 app/F2 G2
    y
    • 2
    • 2
  • d

    Danish Ansari

    12/15/2022, 2:48 PM
    Hi Can someone please help me in achieving this UI(first image) in compose? Till now I have been able to achieve this (second image) with
    Popup
    and
    PopupPositionProvider
    The background and arrow are the most challenging part as it’s position will be dynamic, for eg. arrow will be on top normally and it might be on bottom if the anchoring view (trailing icon of text view) is on bottom of screen and very less space is available below. And the arrow should point exactly to the “help” icon as shown in first image
    c
    e
    a
    • 4
    • 16
  • l

    luke_c

    12/15/2022, 3:44 PM
    It seems like if I pass a data class that has internal visibility to a Composable, then even though the Compose compiler metrics output identifies the parameter as stable it seems to still cause recompositions when the value doesn't change. Removing the internal or adding @Immutable fixes it. Is this expected? Took a few hours to debug that one...
    m
    • 2
    • 2
  • o

    orangy

    12/15/2022, 5:57 PM
    I’m developing a custom layout component (a
    Table
    ) and now I want to draw lines between rows and columns using measures I’ve calculated inside Layout code. How do I do it? Do I have to add artificial components for each line, lay them out and then draw? Or can I somehow feed data after measurements to something like
    drawBehind
    ?
    m
    • 2
    • 2
  • v

    v79

    12/15/2022, 9:01 PM
    Is the material3 website wrong about what's supported in Android? For instance, I was looking for
    FullScreenDialog
    , as listed here https://m3.material.io/components/dialogs/overview - but it's definitely not listed here https://developer.android.com/reference/kotlin/androidx/compose/material3/package-summary !
    m
    c
    f
    • 4
    • 6
  • p

    Puneet Verma

    12/16/2022, 5:45 AM
    Hi, Hope everyone is doing great! I’ve been using Jetpack Compose for a few months now but I can’t seem to find a proper Arch pattern and not in the perspective of the ViewModel but I also want the good approach to handle the State holder and CRUD operations on them. Let me know all the resources Thanks in advance!
    z
    • 2
    • 1
  • l

    lesincs

    12/16/2022, 7:57 AM
    [Compose Navigation]How to avoid repeat request when screen got retained ?
    d
    e
    • 3
    • 4
  • r

    Raphael TEYSSANDIER

    12/16/2022, 9:03 AM
    Hello, does something exist like
    ItemTouchHelper
    in compose for Lazy* ?
  • s

    Sivan

    12/16/2022, 12:30 PM
    Hey folks! Trying to test a
    ModalBottomSheetLayout
    but I am not sure if the assertions are working right. All I am trying to do is to call a button click which opens up the sheet and asserting the sheetState to see if it is visible. Every assertion is failing for some reason. Code and logs in the thread ⬇️
    d
    • 2
    • 4
  • t

    Tower Guidev2

    12/16/2022, 1:43 PM
    Hello... can anyone help with this question on SwipeToDismiss? https://stackoverflow.com/questions/74825269/android-jetpack-compose-androidx-compose-material-swipetodismiss-suspend-fun-dis
    j
    • 2
    • 2
  • o

    orangy

    12/16/2022, 1:57 PM
    I wonder if there is any reason that
    Stroke
    is not a data class? I miss
    copy
    method…
    a
    z
    • 3
    • 2
  • r

    robercoding

    12/16/2022, 2:32 PM
    Is there a way to change the size of an
    Image(...)
    outside of composition phase? 🤔
    z
    • 2
    • 6
Powered by Linen
Title
r

robercoding

12/16/2022, 2:32 PM
Is there a way to change the size of an
Image(...)
outside of composition phase? 🤔
Currently I have an animation changing the size of an
Image
and I kinda dislike that it recomposes a hundred of times, do you know if that's skippable or?
I tried
drawBehind { }
and
drawWithContent
, but sadly this didn't work. I'm guessing there must be another way Edit: I don't want to go through recomposition just because I'm animating something
Is this
size
determined on
Composition
phase? I'm thinking that there should be a way to do this in
Layout
phase right? Since it determines the size & placement of the layout
z

Zach Klippenstein (he/him) [MOD]

12/16/2022, 11:40 PM
You can do it in layout or draw phases, depending on what you actually want to resize. If you want the layout node to resize, ie affect other things around the image, you’ll want to do it in layout. If you don’t need layout, you could do it with a scale transformation in draw with content.
r

robercoding

12/17/2022, 10:03 AM
Yes, that's the answer I needed! Not sure why I couldn't figure it out previously, probably I need more experience 😅 The code I've used, not sure if it can be improved but it's working!
.layout { measurable, constraints ->
    val size = sizeAnimation.toPx()
    val placeable = measurable.measure(Constraints.fixed(size.toInt(), size.toInt()))
    layout(placeable.width,placeable.height) {
        placeable.placeRelative(0, 0)
    }
}
Thank you Zach! :heart_hands:
I was wondering if I can animate the font size of a
Text
and skip recomposition? The above solution (in the thread) doesn't work which makes sense since it affects directly the width/height Do you know if there's a way to do that affecting the position of other layouts around the text? That would mean that
Drawing
phase won't work in this scenario
View count: 97