https://kotlinlang.org logo
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
  • m

    Mjahangiry75

    03/11/2021, 4:38 PM
    how can I clear compose navigation
    BackStack
    ?
    i
    • 2
    • 4
  • g

    Gabriel

    03/11/2021, 6:51 PM
    Anyone know how to get the latest kotlin 1.4.31?
    ➕ 4
    s
    c
    g
    • 4
    • 4
  • a

    alorma

    03/11/2021, 7:03 PM
    What is the best way to load a bitmap with a suspend function? I want to use Google Places sdk and it provide a
    Task
    that returns
    Bitmap
    ... I've added an
    await()
    method to convert it to Bitmap directly... but, how to load it onto Composable?
    a
    • 2
    • 4
  • s

    sen kumar

    03/11/2021, 8:07 PM
    Any idea - why this occurs ? - java.lang.IllegalArgumentException: Layer is redrawn for LayoutNode in state NeedsRelayout [LayoutNode@ef9e093 children: 1 measurePolicy: androidx.compose.ui.layout.SubcomposeLayoutState$createMeasurePolicy$1@2d98fc5]
    a
    • 2
    • 1
  • g

    Gabriel

    03/11/2021, 8:32 PM
    Should we be using something other than
    AppCompatActivity
    ? It's what's in the default when creating a new compose
    j
    s
    +2
    • 5
    • 9
  • s

    Sam

    03/11/2021, 9:10 PM
    Don’t know if this is the right place to discuss but my Compose project is telling me to remove
    jcenter
    but when i do, all hell breaks loose and i can no longer compile
    s
    f
    +5
    • 8
    • 25
  • s

    Sam

    03/11/2021, 9:51 PM
    Does anyone know if
    navigation-compose
    ever added transitions? Trying to catch up on the last several versions but I didn’t see anything in the release notes, and I swear there was an issue about it but nothing related in the issue tracker: https://issuetracker.google.com/issues?q=componentid:409828
    i
    d
    +4
    • 7
    • 21
  • b

    Bradleycorn

    03/11/2021, 9:55 PM
    Some questions around
    navigation-compose
    and ViewModels. For a time now, we've been able to get a viewmodel scoped to a backstack entry (at first by rolling our own factory, then using a HiltViewModelFactory, and now by using
    hiltNavGraphViewModel()
    ). I presume that means that as long as the backstack entry exists, then the VeiwModel will hang around, and won't be cleared until the backstack entry is popped, right? And if so, you might need to be careful in some cases when launching a coroutine using
    viewModelScope.launch
    , right? If your are just making a newtork call to fetch a piece of data or something, no big deal. But if it's a longer running operation, then it will not get canceled until the backstackentry is popped from the stack. So, if say you have Composables A, B, and C that are entries in your graph, and you navigate from A to B to C ... if the ViewModel for A launched a coroutine in its
    viewModelScope
    , it will still be running while the user is looking at C, correct? So if your intention is to launch a coroutine when the user is looking at A and have it get canceled when the user navigates to B, then you really need to use a different mechanism (like say
    LaunchedEffect
    ). Do I have that right?
    ☝️ 1
    i
    a
    k
    • 4
    • 10
  • t

    Tlaster

    03/12/2021, 3:25 AM
    Getting
    Fatal Exception: java.lang.IllegalStateException: LayoutCoordinate operations are only valid when isAttached is true
    from firebase in my app and not sure what was the issue since I may not able to create a reproduce sample, full stacktrace in thread
    a
    • 2
    • 4
  • c

    Colton Idle

    03/12/2021, 4:02 AM
    https://twitter.com/intelligibabble/status/1370138944474472448?s=20
    👍 1
    j
    • 2
    • 1
  • k

    knthmn

    03/12/2021, 7:51 AM
    Style issue regarding lazy lists. In my lazy lists (e.g.
    LazyColumn()
    ), I sometimes want to extract several items in a function. So I define
    fun LazyListScope.FooSection(...) { items....  }
    and use it in my lazy lists
    LazyColumn { FooSection(...) }
    However Android Studio complains the naming since
    FooSection
    is not a composable, I am wondering if this is not something I should do at the first place.
    a
    • 2
    • 1
  • j

    Joost Klitsie

    03/12/2021, 8:09 AM
    Now that Jetpack Compose is in Beta and I get lint errors about `Composable functions that return Unit should start with an uppercase letter`I am slowly starting to realize, after months of denial, the battle for lowercase + camelCase for function names (as per the kotlin coding conventions ) battle is over and lost. I just wanted to vent (I am now refactoring the names of the functions in my code for the upper case start) that it looks weird that within composable functions it looks like I am instantiating a bunch of objects instead of calling actual functions. For all the other rebels that share this thought, I want to give the opportunity to press
    F
    to pay your respects to this fallen topic, and move on to the world of uppercase CamelCase function naming with me.
    b
    f
    v
    • 4
    • 7
  • r

    Radoslaw Juszczyk

    03/12/2021, 8:43 AM
    I am trying to display an image with jetpack compose… which is a normal PNG file inside drawable directory:
    …res/drawable-xxxhdpi/ic_test.png
    the code I use:
    Image(painter = painterResource(id = R.drawable.ic_test), contentDescription = "Test")
    produces this exception:
    java.lang.IllegalArgumentException: Only VectorDrawables and rasterized asset types are supported ex. PNG, JPG
    What am I doing wrong?
    t
    • 2
    • 2
  • p

    Piotr Prus

    03/12/2021, 8:46 AM
    I am wondering if canvas drawing should be used for simple shapes if you can use Compose instead. Let’s assume I want to draw Bar Chart. This can be achieved with drawOnCanvas, but also using just Compose Boxes. Furthermore, if BarChart will be very wide and horizontally scrollable, in Compose I could use LazyRow which is not a case for Canvas. What you guys think?
    a
    • 2
    • 1
  • a

    allan.conda

    03/12/2021, 9:06 AM
    Is there a good way to declare a text with a clickable link in Compose yet?
    f
    z
    +3
    • 6
    • 21
  • a

    André Kindwall

    03/12/2021, 9:08 AM
    Is there a compose equivalent to
    android:keepScreenOn
    ?
    k
    a
    c
    • 4
    • 8
  • j

    julioromano

    03/12/2021, 9:36 AM
    Any one tried constraintlayout-compose alpha04? It seems it broke some existing layouts. I can’t find any release notes though, can someone point me to them?
    ✅ 1
    a
    s
    n
    • 4
    • 6
  • m

    Marcin Środa

    03/12/2021, 9:51 AM
    Did anyone saw strange FloatingButton animation in newest compose release? In
    Scaffold
    it’s like animating from left to right after update. How to disable it? 🙂 It’s lagging on emulator
    f
    • 2
    • 2
  • a

    Albert Chang

    03/12/2021, 1:19 PM
    It seems that in beta02 if I add
    uiMode
    to
    android:configChanges
    of the activity, the app will only react to the first dark mode change. Just want to make sure I'm not missing anything.
    a
    • 2
    • 2
  • u

    Utkarsh Tiwari

    03/12/2021, 3:07 PM
    Is there way to increase the duration of
    AnimatedVisibility
    ? I want to slow the animation a bit.
    👀 1
    a
    • 2
    • 1
  • u

    Ujwal

    03/12/2021, 4:43 PM
    Hi all, I am trying to dynamically adjust the space between the components in my content depending on the visible screen height (keyboard up or not). My content consists of multiple components that are optional, so it could be somewhere between 2 to 10 components. I Don't want to change the height of my components, but only the space between them. So, I would like to have something like min and max height for the spacers in between, so that max height is used when the screen has it. Then it should start to shrink the height slowly as necessary until it reaches min value. Then it should start to scroll after reaching the min value. I am trying to solve 2 problems here; 1. When the keyboard is up. 2. Phones with smaller screens. Any suggestions please..
    a
    • 2
    • 14
  • j

    jannis

    03/12/2021, 6:13 PM
    How do you guys handle complex composables with many parameters? I can combine the value parameters to a state object (which generates more boilerplate code), but I'm unsure what to do if the user can do a lot of stuff. E.g. I have tons of callback methods to pass events to my ViewModel. Also define an Interface with all the possible methods?
    👍 2
    j
    f
    +3
    • 6
    • 11
  • d

    Desmond Teo

    03/12/2021, 6:18 PM
    Does anyone know how to pass arguments to the start destination of a nested graph?
    i
    • 2
    • 3
  • e

    escodro

    03/12/2021, 7:17 PM
    Hello, everyone! 👋 I published an article with some ideas for handling state between the Composable and ViewModel, based on some conversations with @Adam Powell. I hope that this content can help you the way that helped me. 😊 Thanks a lot! ❤️ https://proandroiddev.com/better-handling-states-between-viewmodel-and-composable-7ca14af379cb
    🙂 4
    j
    • 2
    • 3
  • r

    Rick Regan

    03/12/2021, 8:43 PM
    I'd like to do a
    Crossfade
    on a
    Text
    when it is set to the empty string, but not when it is updated in any other way. This code will crossfade for every update to the state 'text'
    Crossfade(targetState = text, animationSpec = tween(1000)) { newText ->
        Text(text = newText)
    }
    but I'd only like it to apply when 'text' is cleared. Is it possible to do this with Crossfade, or do I need some other animation mechanism? (I didn't expect using
    if (text.isEmpty())
    with a crossfaded Text in the
    if
    and just a Text in the
    else
    to work, but I tried it anyway and it didn't.)
    a
    d
    • 3
    • 13
  • c

    Colton Idle

    03/12/2021, 8:52 PM
    Tried looking at cs.android.com, but I wasn't able to find if there's a Compose implementation of "Autosizing TextViews" from XML land. Is this possible at the moment?
    o
    k
    m
    • 4
    • 4
  • g

    Gabriel

    03/12/2021, 10:21 PM
    Does compose have native date/time pickers ? Google results reference a library atm
    e
    • 2
    • 1
  • l

    Lilly

    03/12/2021, 11:26 PM
    By using the search function I can't find anything about
    Shared Preferences
    . Just the hint, that it's not the right data storage solution. I would like to save some settings. What's the right way to store such data persistently?
    s
    j
    i
    • 4
    • 7
  • k

    Konyaco

    03/13/2021, 3:19 AM
    I think Crossfade should not clip graphicsLayer. When crossfade is animating, it uses:
    keys.mapTo(items) { key ->
        CrossfadeAnimationItem(key) {
            val alpha by transition.animateFloat(
                transitionSpec = { animationSpec }
            ) { if (it == key) 1f else 0f }
            // NOTICE
            Box(Modifier.alpha(alpha = alpha)) {
                content(key)
            }
        }
    }
    And if it is not animating, it uses:
    Box(modifier) {
        items.fastForEach {
            key(it.key) {
                it.content()
            }
        }
    }
    The problem is, 
    Modifier.alpha()
      is an alias of 
    graphicsLayer(alpha = alpha, clip = true)
     , If you are holding a Button, Card or anything with shadow, Crossfade will clip the shadow when animation starts, and resume when animation finishes, that will be very unnatural. And I wonder the reason that 
    Modifier.alpha()
     sets 
    clip
     property to true, is that really necessary?
    d
    n
    • 3
    • 6
  • r

    robnik

    03/13/2021, 4:26 AM
    Updated AS and now I get gradle build error:
    Could not find org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.30.
    What? Anyone else have this problem? I have two repos in gradle file:
    google()
    and
    mavenCentral()
    .
    l
    • 2
    • 2
Powered by Linen
Title
r

robnik

03/13/2021, 4:26 AM
Updated AS and now I get gradle build error:
Could not find org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.30.
What? Anyone else have this problem? I have two repos in gradle file:
google()
and
mavenCentral()
.
l

lewis

03/13/2021, 6:52 AM
Try adding
jcenter()
Not all Kotlin deps have been republished
View count: 6