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

    Orhan Tozan

    03/02/2021, 5:01 PM
    What is Jetpack Compose's replacement for
    android:includeFontPadding="false"
    ? Can't seem to find it.
    r
    s
    +3
    • 6
    • 16
  • e

    escodro

    03/02/2021, 5:21 PM
    Hello, everyone! I’m having some issues with ViewModel + Hilt + Navigation. I already took a look at previous discussions but I need some advice. I have a
    Home
    screen that contains 4 tabs, each one with its own
    ViewModel
    . Today it is declared this way:
    composable(Destinations.Home) {
        Home(
            onTaskClicked = actions.openTaskDetail,
            onAboutClicked = actions.openAbout
        )
    }
    But since calling
    viewModel()
    to get the ViewModels for each Composable does not work, how should I proceed? Get the 4 ViewModels inside my
    NavGraph
    and pass then all to my
    Home
    ? Should I create a
    HomeViewModelProvider
    containing the 4 ViewModels? Is there a better approach? Thanks a lot in advance! ❤️
    i
    c
    • 3
    • 4
  • t

    Tony Kazanjian

    03/02/2021, 5:22 PM
    I am trying to add an auto-scroll effect to the example of a Pager seen in the Jetcaster sample (https://github.com/android/compose-samples/blob/main/Jetcaster/app/src/main/java/com/example/jetcaster/util/Pager.kt), but it seems like adding a
    ScrollableState
    to a modifier that also includes a
    DraggableState
    has no effect (also, seems like whichever modifier comes next pretty much overwrites the previous one). Code in thread
    ✅ 1
    • 1
    • 2
  • j

    John O'Reilly

    03/02/2021, 5:55 PM
    Am updating a project here from alpha11 to beta01 and getting
    Unresolved reference: BottomDrawerLayout
    - I might be missing something obvious but I've searched this channel/web but didn't see anything about that changing
    l
    • 2
    • 2
  • b

    Bryan Herbst

    03/02/2021, 6:52 PM
    What is the right way to get a callback when a
    ModalBottomSheetLayout
    is dismissed, either from accessibility actions or from tapping on the scrim outside the sheet? Drop a
    DisposableEffect
    inside the sheet’s content? I don’t see any sort of callback or observable state.
    k
    m
    • 3
    • 5
  • z

    zoha131

    03/02/2021, 7:02 PM
    Why do we have three different over load of
    AnimatedVisibility
    . More specifically why do we have
    RowScope
    and
    ColumnScope
    version of implementations? Isn’t without scope one is enough? I think I have seen this pattern for couple of other Composables. My curious minds wants to the reason behind it. 🧐
    ❓ 1
    j
    z
    • 3
    • 4
  • o

    Orhan Tozan

    03/02/2021, 7:28 PM
    What is the recommended way to respond to flows that act like events/side effects in Compose? E.g. a viewmodel with a Flow<NavigateToFoo>
    s
    • 2
    • 59
  • a

    Alexander Pataridze

    03/02/2021, 7:31 PM
    Any chance of getting Compose for iOS?
    🙏 1
    j
    t
    +5
    • 8
    • 9
  • d

    Daniel

    03/02/2021, 11:48 PM
    Can I detect taps outside of a component? I want to have a dropdown collapse itself on tap outside of it, without needed to require every parent to listen for tap events and tell it to close
    z
    l
    • 3
    • 7
  • s

    Sam

    03/03/2021, 1:49 AM
    just came to say that upgrading from
    alpha11
    to
    beta01
    is borderline unconstitutional, 600+ compile time errors down, still 44 more to go — fingers crossed our app actually works at runtime
    z
    i
    • 3
    • 4
  • a

    Arkadii Ivanov

    03/03/2021, 2:46 AM
    Puppy For You! My submission to #AndroidDevChallenge: GitHub. 🐕❤️
    out.mov
    🎉 10
    🐶 2
    b
    t
    • 3
    • 2
  • c

    Colton Idle

    03/03/2021, 2:57 AM
    Any tips on how to get height and width of a composable at runtime after it's been drawn to the screen? My backend accepts a height and width param for an image url, but I won't know the exact size to request the image until it's laid out and so I'm looking to write a composable that knows how to do this using glide + accompanist. Just need a hint in terms of how I can get width and height after it's laid out I think. The fact that I'm using glide + accompanist is a detail (i think 😄 ) In classic android view-land we did this by making use of the ktx method called doOnLayout
    fun ImageView.loadImageToSize(url: String) {
        this.doOnLayout { <--- ktx method that replaced OnGlobalLayoutListener
             // it.width and it.height are accessible here
    ...
    }
    a
    e
    • 3
    • 13
  • s

    Shivam Sethi

    03/03/2021, 3:27 AM
    How can I enable typing with hardware keyboard in a TextField composable ? One of the app user is unable to type in because they have a blackberry device with hardware keyboard ?
    👍 2
    c
    s
    • 3
    • 7
  • j

    jacksparling

    03/03/2021, 5:00 AM
    Why the android studio preview arctic fox 3.1 canary 8 keep telling me 'Invalid Gradle JDK configuration found.'? I've check the path it uses JDK 11 which is added in the directory of android studio preview.
    i
    • 2
    • 12
  • t

    Tlaster

    03/03/2021, 5:19 AM
    Has anyone getting error
    java.lang.IllegalArgumentException: 0 was already used with subcompose during this measuring pass
    after beta01 when setting
    initialFirstVisibleItemIndex
    for LazyColumn? Full stacktrace in thread.
    a
    j
    a
    • 4
    • 7
  • v

    Vinay Gaba

    03/03/2021, 5:35 AM
    I’m seeing some weirdness on beta-01 as I’m trying to upgrade my library. I’ve zeroed down the issue to the use of a
    TextField
    as the
    title
    slot of a
    TopAppBar
    . I’m actually using a
    TextField
    or a
    Text
    depending on some state (search being active vs not). The thread has more details. Has anyone noticed something similar?
    e
    t
    • 3
    • 17
  • w

    wiktorl4z

    03/03/2021, 9:08 AM
    Anyone had problem with spotless? I have uber newbie code:https://github.com/Wiktorl4z/dev-challenge/blob/week1_bark/app/src/main/java/com/example/androiddevchallenge/MainActivity.kt and I have an error.
    > Task :app:spotlessKotlin FAILED
    Can't parse copyright year '', defaulting to 2021
    Step 'ktlint' found problem in 'app\src\main\java\com\example\androiddevchallenge\MainActivity.kt':
    Error on line: 26, column: 1
    Wildcard import
    java.lang.AssertionError: Error on line: 26, column: 1
    I assume that he has problems with reading the copyright but It's default one..
    a
    b
    • 3
    • 6
  • o

    Orhan Tozan

    03/03/2021, 10:03 AM
    I have the following code
    OutlinedButton(shape = RoundedCornerShape(28.dp))
    It looks like it only applies it to the top corners? Is this a bug?
    a
    n
    n
    • 4
    • 8
  • n

    note8g2018

    03/03/2021, 10:12 AM
    Please tell Google to update the code lab for jetpack compose https://developer.android.com/courses/pathways/compose It is not working now Because the code is old and there are many huge changes in the framework jetpack compose Google should update the code
    g
    n
    +2
    • 5
    • 5
  • d

    Daniel

    03/03/2021, 11:58 AM
    I was accidentally also running the layout inspect, seems like that was the issue
    z
    j
    • 3
    • 6
  • s

    Slackbot

    03/03/2021, 12:48 PM
    This message was deleted.
    l
    • 2
    • 1
  • k

    Kulwinder Singh

    03/03/2021, 1:17 PM
    Hi, is anything similar in compose like Flutter Navigation ? for example opening different Scaffolds directly ?
    j
    s
    +2
    • 5
    • 6
  • a

    Adriano Celentano

    03/03/2021, 1:44 PM
    im struggling a bit to understand subcomposeLayout, someone has a super simple explanation / example somewhere ?
    👍 5
    a
    d
    • 3
    • 4
  • k

    Kevin Aude

    03/03/2021, 2:07 PM
    I’m a bit lost with navigation in compose, I based my code of the Owl example but seem to have miss something. Any help would be appreciated. Code in thread
    v
    j
    • 3
    • 9
  • h

    Halil Ozercan

    03/03/2021, 2:18 PM
    forgive my sarcasm but do I need a PhD to understand how to implement a custom gesture detector? It's nice that there is a selection of gesture detectors pre-defined under
    pointerInput
    but when I tried implementing my own, I got totally lost. My first try was a quick failure because predefined detectors consume the events so they cannot be used together. On my second attempt, I tried to write my own detector with lower level
    await
    calls and got confused so hard. Is there a documentation that would shine even a little light on this API?
    d
    v
    z
    • 4
    • 17
  • z

    zhuinden

    03/03/2021, 2:41 PM
    hey, i'm looking for help regarding custom animations using Compose.
    :thread-please: 2
    z
    a
    +2
    • 5
    • 63
  • p

    Piotr Prus

    03/03/2021, 3:22 PM
    Guys, I encountered really big issue with compose view on Huawei devices (with Google services). The compose library is working very slow or even not working in some cases at all. For quick reproduction, you can download the
    Crane
    app sample, provide your google map api and make only one small change, enable gestures on map. The map will not update on your gestures until you tap on button or any other interactive element on screen. Anyone encounter such behavior? I am building the mapApp and this behaviour occurs only on Huawei devices.
    j
    • 2
    • 2
  • z

    Zhelyazko Atanasov

    03/03/2021, 3:31 PM
    Does anybody know what's the difference between having a
    Modifier
    passed in as an argument and then adding more modifiers on top of it, e.g.:
    fun Info(modifier: Modifier) {
        Text(modifier.size(16.dp)
    }
    Versus having the same case, but using
    then
    to merge the 2 modifiers:
    fun Info(modifier: Modifier) {
        Text(modifier then Modifier.size(16.dp)
    }
    a
    d
    • 3
    • 4
  • d

    Daniel

    03/03/2021, 4:12 PM
    I needed a [Material ExposedDropdownMenu](https://material.io/components/menus#exposed-dropdown-menu), so I built one by combining an OutlinedTextField and a DropdownMenu. What I've built works, but feels a little hacky. I ended up needing to use SubcomposeLayout and MutableInteractionSource for the first time. Does that sound reasonable? The code: https://gist.github.com/danielzfranklin/6af017eec110dee4980167bb833077ef I use SubcomposeLayout because DropdownMenu opens a popup outside the normal flow, so if I want it to be properly positioned and sized I need to know the size of the field. I use MutableInteractionSource to make the text field focused when the menu is expanded, and visa-versa.
    a
    t
    • 3
    • 10
  • f

    FunkyMuse

    03/03/2021, 5:42 PM
    java.lang.UnsupportedOperationException: Arrays don't support default values. Does anyone know why I can't pass StringArrayType in compose navigation?
    i
    g
    g
    • 4
    • 33
Powered by Linen
Title
f

FunkyMuse

03/03/2021, 5:42 PM
java.lang.UnsupportedOperationException: Arrays don't support default values. Does anyone know why I can't pass StringArrayType in compose navigation?
i

Ian Lake

03/03/2021, 5:48 PM
Routes, the way of navigating between destinations, are like URIs. They don't support arrays or complex types. What are you trying to do?
f

FunkyMuse

03/03/2021, 5:48 PM
Trying to pass list/array of strings to a navigation composable
The string list/array consists of 5 dynamic URLs that i need to provide everytime i open that screen
i

Ian Lake

03/03/2021, 5:51 PM
Okay, so why 5 dynamic URLs?
f

FunkyMuse

03/03/2021, 5:51 PM
Because i have these 5 urls on the list screen and i want to have them in the details screen
And they're different for every list item
i

Ian Lake

03/03/2021, 5:52 PM
So every list item has 5 urls associated with it?
f

FunkyMuse

03/03/2021, 5:53 PM
True
i

Ian Lake

03/03/2021, 5:53 PM
So you should be passing the ID of the list item through your arguments, not the individual fields of the list item, same as if you were trying to pass a Parcelable
👍 1
f

FunkyMuse

03/03/2021, 5:53 PM
When i open the details, i call an API with the id as the first navigation (route) parameter passed to the navigation and these 5 URLs as a second parameter
Because in the details of the API i don't have these URLs
Limitations of the backend
i

Ian Lake

03/03/2021, 5:57 PM
It seems like the same approach suggested for Parcelables, or any complicated set of data, also applies here. Don't send all your content your arguments. https://kotlinlang.slack.com/archives/CJLTWPH7S/p1604087992002000?thread_ts=1604053414.451400&amp;cid=CJLTWPH7S
g

Gabriel Melo

03/03/2021, 5:58 PM
Is there somewhere where you elaborate on the rationale behind this design choice, @Ian Lake? I don't quite understand the choice to stop supporting navigation with complex arguments.
i

Ian Lake

03/03/2021, 5:58 PM
You mean, like in that thread I just linked?
g

Gabriel Melo

03/03/2021, 5:59 PM
The thread says what to do, not really why. Unless I missed something.
I'll check it again.
i

Ian Lake

03/03/2021, 5:59 PM
https://kotlinlang.slack.com/archives/CJLTWPH7S/p1604071569473300?thread_ts=1604053414.451400&amp;cid=CJLTWPH7S
g

Gabriel Melo

03/03/2021, 6:00 PM
I guess this is what I was looking for: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1604962773208700?thread_ts=1604053414.451400&amp;cid=CJLTWPH7S
But again, this seems more like an argument in favour of caching than against complex navigation arguments. It seems to me that this approach requires the new view to sort out its own dependencies instead of allowing the previous one provide them.
f

FunkyMuse

03/03/2021, 6:06 PM
Is there a possibility to obtain the view model holding the list somehow, like scope it to the previous backstack entry or something and just get the model with the id from that list?
i

Ian Lake

03/03/2021, 6:14 PM
Again, you have keep in mind that your app can be killed and then later restored at any point in time. It will come back up at the same destination it is at, but any ViewModel / in memory only information is going to be lost
👍 2
f

FunkyMuse

03/03/2021, 6:15 PM
Same goes with in memory database as a temp data holder for the URLs?
i

Ian Lake

03/03/2021, 6:16 PM
Your list of items should already be just displaying data from a local repository; your detail view should just be accessing that same local repository
👍 3
f

FunkyMuse

03/03/2021, 6:44 PM
Right, so there's no way to pass lists as nav argument to compose at all?
g

Gabriel Melo

03/03/2021, 6:49 PM
It's not currently supported and there are no plans to support it AFAIK.
😢 1
It may be a blessing in disguise, @FunkyMuse. It will "force" us to think about a single source of truth, persistence and process death.
f

FunkyMuse

03/03/2021, 6:52 PM
Yeah true that, some habits die hard
but i guess there should be an information pointing that
since NavType.StringArray still exists
then i guess Parcelize won't have much usage in the future, i.e deprecateD?
g

Gabriel Melo

03/03/2021, 8:47 PM
I believe it still has its place in passing arguments to activities and fragments, just not composables.
g

Gabriel Feo

03/04/2021, 1:08 AM
Compose still needs to interface with the platform. The underlying APIs are unlikely to stop using Bundles and Parcelables. We’ll still use
@Parcelize
for state restoration going forward: https://developer.android.com/jetpack/compose/state#restore-ui-state
View count: 9