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

    Nat Strangerweather

    02/05/2022, 6:12 PM
    If I were to make an app like this word finder game in Compose, what gesture detector would I need to use? As it stands I can get each letter using the onpress gesture detector , but I guess this is more of a swipe gesture. Is this possible in Compose or would I need to use a games engine? See picture in thread.
    👀 1
    a
    • 2
    • 6
  • t

    Tolriq

    02/05/2022, 7:05 PM
    Is there something special in AlertDialogs and focus/keyboard?
    LaunchedEffect(Unit) {
    	focusRequester.requestFocus()
    	keyboardController?.show()
    }
    Does not work I need to add a delay before the show() but this feels hacky and random value 😞
    z
    j
    • 3
    • 3
  • l

    Landry Norris

    02/05/2022, 7:59 PM
    In general, will individual state variables be faster than a single data class that holds all the state for a screen? I know that when using individual variables, Compose will only re-render Composables that use the value of the variable that was changed. When using a single data class, is Compose smart enough to only re-render Composables that use the fields that changed, or will it re-render every Composable that uses any field of the single state variable?
    a
    • 2
    • 19
  • j

    james

    02/06/2022, 1:24 AM
    with navigation animations via Accompanist library, does anyone know if there's a way to define your animation(s) at the time of calling
    navController.navigate()
    ? my use case is that I have a dynamic screen which can be accessed by either tapping through the UI, and it can be nested many levels deep, and my animation for sliding in and out works great there, but this dynamic screen can also be accessed via the hamburger menu, and when it's accessed from there, I want to clear the backstack (which is the easy part) but I also want the transition to be different, because sliding in feels and looks totally wrong there is this possible? or will I need to create entirely different routes and
    composable(transition = )
    declarations and just use different routes to display the same screen but with alternate transition animations?
    i
    • 2
    • 5
  • m

    mattinger

    02/06/2022, 4:57 AM
    So, if i'm using the accompanist pager library, and I have a horizontal pager, I would like to add some sort of callback to know when the user actually swiped to change pages (as opposed to just a general change of pages which could also be triggered programmatically as say a response to a button click). I'm not sure how i'd do that, but my first instinct was a custom FlingBehavior, but that doesn't really seem to be the right thing. Is it even possible to get a callback like this? I also thought of setting a flag or something in the onClick callback to indicate if the button was clicked so that as i collect the changes in the pageState, i would know if it was a swipe or click.
    y
    • 2
    • 2
  • r

    Rooparsh

    02/06/2022, 7:20 AM
    Hi, Recently I have been trying Maps Compose https://twitter.com/i_am_rooparsh/status/1489892409534480386?s=21 Today, I noticed some strange behaviour in Maps. As per my emulator location spoofing, my location was supposed to be between 2 towns (Ludhiana and Patiala) which lie in India. But on maps, My location was shown somewhere in United States. On Further digging, I found that the issue was with latitude and longitude returned from Location class in gms package. Attaching a screen recording, wherein you can see lat and long that are in emulator and that my app is receiving. Not sure where the issue is .
    o
    • 2
    • 3
  • y

    YASAN

    02/06/2022, 11:05 AM
    I have a composable function that gets 3 State<T> params. Is it better to send State/MutableState in params or the value inside them?
    d
    a
    +2
    • 5
    • 22
  • e

    elye

    02/06/2022, 12:01 PM
    Hi, Is Compose Animation’s
    Crossfade
    can do a subset of what
    AnimateContent
    can do? Or does
    Crossfade
    has more to offer that can’t be done by
    AnimateContent
    ? (Just curious, why do we need a
    Crossfade
    function specifically, given looks like
    AnimateContent
    can achieve what
    Crossfade
    offers). More detail in https://stackoverflow.com/questions/71006883/is-jetpack-compose-crossfade-just-a-subset-functionality-of-animatecontent Thanks.
    d
    • 2
    • 2
  • g

    galex

    02/06/2022, 5:56 PM
    What’s the best way to get a callback when an item is 100% visible in a
    LazyColumn
    and another callback when it becomes invisible? I’m at lost with the side effects… 😕
    m
    f
    • 3
    • 43
  • m

    myanmarking

    02/06/2022, 7:32 PM
    How to create a custom layout with AndroidView?. For some reason, the measured height of the AndroidView occupies all height. I checked, and it is the wrapper view that has that size. The real view has it’s size correct. Any help ?
    z
    • 2
    • 25
  • s

    skoric

    02/06/2022, 9:59 PM
    Is there a way to wrap the content of the TextField below minimum width, which I've found out in source to be
    280.dp
    ? So I want width to wrap around letters as you enter them and delete. I've been trying to resolve this for days. It just seems there's no solutions.
    f
    • 2
    • 1
  • t

    Tim Malseed

    02/07/2022, 1:25 AM
    Is there a way to implement a sort of recursive navigation route with compose navigation? In this app, you can navigate to, e.g.
    topics/topic1
    , or
    topics/topic1/topics/topic2
    . The depth of recursion is undefined.. I’m not sure how to implement this, as implementing a composable for each possible level, e.g.
    composable(topic/{topicId}/subTopic{subTopicId}/moreSubtopic/{moreSubTopicId}
    doesn’t seem practical
    i
    • 2
    • 10
  • z

    Zoltan Demant

    02/07/2022, 7:37 AM
    If I know that a variable is `@Immutable`; but I cant mark it directly myself - is there another way to acheive the same thing/optimizations? 🧵👀
    • 1
    • 2
  • j

    Joan Colmenero

    02/07/2022, 8:05 AM
    Hello is there any way to test with compose-ui-test that a Text has the text color that I expect? Or a Row/Column that has the background color that I expect?
    m
    • 2
    • 1
  • a

    Alderson Elliot

    02/07/2022, 9:03 AM
    I created a stackoverflow question, can anyone help me (https://stackoverflow.com/questions/71015279/when-opening-dropdownmenu-how-can-i-cancel-keyboard-auto-close-behavior)
    o
    • 2
    • 5
  • t

    Tin Tran

    02/07/2022, 10:13 AM
    Hi! Does compose navigation support deep link with multiple domains?
    f
    • 2
    • 2
  • f

    Filip Stanis

    02/07/2022, 1:58 PM
    Is there something akin to
    .replace
    that works on
    TextFieldValue
    (takes cursor / selection into account)? I'm trying to have forbidden characters (like @) in my
    TextField
    so I'm just doing
    .replace("@", "")
    inside
    onValueChange
    but this means the cursor will stay on the position of the removed character (i.e. behaves like "insert" key is on). I feel this is simple to solve, but just wanted to check if there's some builtin method I'm missing.
    o
    s
    • 3
    • 5
  • m

    mattinger

    02/07/2022, 2:17 PM
    So, i’m having an interesting issue that i’m not sure is technically a compose bug or an android studio bug. If i create a view that extends AbstractComposeView, and then reference that in an xml file, i can’t get a preview, and see this error. Looking for input on wherew to submit this bug. (for the record, i’m using ConstraintLayout 2.0.4)
    java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from androidx.constraintlayout.widget.ConstraintLayout{18da14ef V.E...... ......I. 0,0-0,0}   at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareViewTreeRecomposer(WindowRecomposer.android.kt:244)   at androidx.compose.ui.platform.WindowRecomposer_androidKt.access$createLifecycleAwareViewTreeRecomposer(WindowRecomposer.android.kt:1)   at androidx.compose.ui.platform.WindowRecomposerFactory$Companion$LifecycleAware$1.createRecomposer(WindowRecomposer.android.kt:99)   at androidx.compose.ui.platform.WindowRecomposerPolicy.createAndInstallWindowRecomposer$ui_release(WindowRecomposer.android.kt:155)   at androidx.compose.ui.platform.WindowRecomposer_androidKt.getWindowRecomposer(WindowRecomposer.android.kt:230)   at androidx.compose.ui.platform.AbstractComposeView.resolveParentCompositionContext(ComposeView.android.kt:220)   at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:227)
    • 1
    • 1
  • b

    Brian Donovan

    02/07/2022, 3:00 PM
    Hey all, can someone explain to me in layman terms what this means.: Jetpack Compose is an instrumentation test,you can use a test framework such as Espresso. thanks
    m
    • 2
    • 2
  • v

    Vsevolod Kaganovych

    02/07/2022, 3:28 PM
    Guys, is there a way to enable/disable the OS back button but not to override the default behaviour? The only thing that is available right now is this
    BackHandler(!state.isLoading) {}
    If I do like this, the back button doesn't work even if the
    isLoading
    variable is
    false
    .
    f
    • 2
    • 2
  • f

    Filip Stanis

    02/07/2022, 4:42 PM
    Wrapping a
    Flow<List<Entity>>
    I get from Room into either a
    SharedFlow
    or a
    StateFlow
    seems to prevent it from working (I get the initial list of items from Room, but it never updates). What could be causing this? (code in first reply)
    c
    c
    • 3
    • 7
  • b

    Brian Donovan

    02/07/2022, 5:15 PM
    Hey all, trying to write some tests. Can I get some help with the method please. thanks
    z
    h
    +2
    • 5
    • 14
  • o

    OG

    02/07/2022, 8:59 PM
    Hello everyone, 👋 I was wondering if anyone has any suggestions on the best way to approach building a curved/arced horizontally scrolling list of items with "Snap to Center" behavior + having the beginning of the list positioned in the center of the screen. I've found an article that does something like what I am trying to do, but with RecyclerView + custom layout manager. Posted gif from link below for quick reference as well.
    z
    d
    +2
    • 5
    • 23
  • l

    Lukasz Burcon

    02/07/2022, 9:16 PM
    Hey, have you ever had any problems or weird behaviours when chaining modifiers? I’m passing
    Modifier.requiredSize(50.dp)
    to
    MyTestComposable
    , and I expected that I would override the size with the new value -
    50.dp
    . And yeah, the size is being modified, but somehow when I try to use
    MyTestComposable
    in a Column it looks like another view is being drawn on top of
    MyTestComposable
    - take a look at the picture attached in thread.
    @Composable
    private fun MyTestComposable(
        modifier: Modifier = Modifier,
    ) {
        Box(
            modifier = Modifier
                .border(1.dp, Color.Blue)
                .requiredSize(25.dp)
                .then(modifier)        ,
        )
    }
    m
    • 2
    • 6
  • b

    brabo-hi

    02/08/2022, 12:50 AM
    Hi all, when using a
    Scaffold
    how can we get the
    TopAppBar
    and
    BottomAppBar
    to be transparent and have the body background visible top and bottom?
    c
    • 2
    • 5
  • m

    Marcin Wisniowski

    02/08/2022, 1:52 AM
    I can use
    maxLines = 5
    on a
    Text
    to limit it to 5 lines, but how do I make it always take the space of 5 lines, even if there is less text? I'm looking for a
    minLines = 5
    , if there was one.
    ➕ 4
    z
    f
    w
    • 4
    • 6
  • a

    Ashu

    02/08/2022, 7:30 AM
    Hi, does TextField always keep focus? I want it to loose focus whenever I click outside of it but that isn't happening. Even when I open a dialog box, after the dialog box closes it keeps focus. How can I remove TextField focus whenever I click outside of it?
    z
    • 2
    • 2
  • w

    Waleed Sarwar

    02/08/2022, 8:17 AM
    Hi, I build the app complete app using jetpack compose now we need to add tooltips for onboarding which looks kind of overlay on the UI as shown in the screenshot. Any Idea how to build it. Should I use a constraint layout and create overlay Ui on each screen
    s
    m
    • 3
    • 2
  • e

    elye

    02/08/2022, 11:54 AM
    Hi @Doris Liu, an animation related inquiry. I can’t seems to find any additional benefit of
    MutableStateTransition
    compare to normal
    mutableStateOf
    has to offer. It’s long to describe here, so I have put the inquiry on StackOverflow https://stackoverflow.com/questions/71033419/whats-the-use-of-mutablestatetransition-looks-like-mutablestateof-does-all-i. Hopes to get some insight from you. Thanks 🙏
    • 1
    • 1
  • m

    Marcin Wisniowski

    02/08/2022, 1:03 PM
    What's the relationship between
    elevation
    and
    zIndex
    ? They seem to affect each other, but I am not sure how exactly.
    f
    • 2
    • 2
Powered by Linen
Title
m

Marcin Wisniowski

02/08/2022, 1:03 PM
What's the relationship between
elevation
and
zIndex
? They seem to affect each other, but I am not sure how exactly.
f

Filip Wiesner

02/08/2022, 1:06 PM
elevation
in the material design refers to the theoretical elevation of the element and the resulting shadow. The
zIndex
should be purely the draw order in a scope.
From
shadow()
modifier documentation:
Note that elevation is only affecting the shadow size and doesn't change the drawing order. Use a androidx.compose.ui.zIndex modifier if you want to draw the elements with larger elevation after all the elements with a smaller one.
View count: 4