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

    Vinay Gaba

    12/20/2020, 2:11 AM
    I encountered a lint rule that doesn’t allow me to pass a custom default modifier to a method and instead recommends that I simply use the default
    Modifier
    // Not allowed
    fun TestComponent(
        modifier: Modifier = Modifier.fillMaxWidth().preferredSizeIn(maxHeight = 200.dp)
    )
    
    // Instead, it recommends that you do this
    fun TestComponent(
        modifier: Modifier = Modifier
    )
    Could someone shed some more light on why this is a guideline? Since this is intentionally enforced, I’m sure there is a very good reason to do this. It’s obviously more reusable which makes complete sense but I wonder if this is one place where it would be okay to have some flexibility.
    a
    • 2
    • 8
  • c

    Colton Idle

    12/20/2020, 4:08 AM
    I got compose to work in one existing project of mine. Now I'm trying to add it to another and I'm getting NoSuchMethodError: No static method setContent Any ideas? I have
    buildFeatures {
    compose = true
    }
    
    composeOptions {
    kotlinCompilerVersion '1.4.21'
    kotlinCompilerExtensionVersion '1.0.0-alpha09'
    }
    kotlinOptions with useIR = true and jvmTarget set to 1.8 What else could be going wrong? I'm getting a crash at runtime. Everything in the IDE (latest canary) looks fine. Gist: Latest everything. No compile issues. Runtime issue when just hitting
    setContent
    and nothing else. Edit: Only other thing I can think of is that I use some dependency that is forcing an older version of kotlin? I tried to use ./gradlew dependencies to figure out, but everything looks like its 1.4.21 Another edit: There literally has to be a better way to get a better error message. Literally have no idea whats going on 😭 I already have been able to get compose working in past projects. I quadruple checked that I followed these steps correctly https://developer.android.com/jetpack/compose/setup#add-compose (except that I'm using kotlin 1.4.21, alpha09 of compose, and Canary 3 of AS. Could really use any bump in the right direction. Thanks!
    j
    j
    • 3
    • 53
  • k

    Kshitij Patil

    12/20/2020, 10:26 AM
    Does anyone have paging 3 RemoteMediator implementation with Jetpack Compose?
    z
    • 2
    • 1
  • j

    John O'Reilly

    12/20/2020, 10:38 AM
    What , if anything right now, would be considered Compose's equivalent of SwiftUI's
    @Binding
    ?
    k
    r
    • 3
    • 4
  • a

    Alexander Karkossa

    12/20/2020, 10:46 AM
    Any plannings for adding these function?
    <R, T : R> LiveData<T>.observeAsState(initial: R, *policy: SnapshotMutationPolicy<R>*): State<R>
    a
    • 2
    • 3
  • k

    Kshitij Patil

    12/20/2020, 5:50 PM
    We no longer need to use
    ExperimentalFocus
    annotation right? Not sure if it was removed in
    alpha08
    or
    alpha09
    a
    • 2
    • 1
  • a

    Alexander Karkossa

    12/20/2020, 7:08 PM
    Hey, we use the
    BottomDrawerLayout
    . Since the use of
    nestedScroll
    within the
    BottomDrawerLayout
    , Lists in the Views won't scroll anymore. Even if we set
    gesturesEnabled = false
    , the Drawer opens when trying to scroll a list. Any ideas?
    👀 1
    t
    a
    • 3
    • 4
  • m

    Mehdi Haghgoo

    12/21/2020, 6:34 AM
    Hi. Why do we use the following in build.gradle?
    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
        kotlinOptions {
            jvmTarget = "1.8"
            freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
        }
    g
    j
    • 3
    • 4
  • k

    Kshitij Patil

    12/21/2020, 7:21 AM
    What is paging-compose equivalent for
    adapter.retry()
    ?
    • 1
    • 1
  • m

    Mehdi Haghgoo

    12/21/2020, 7:53 AM
    Could not find androidx.ui:ui-tooling:1.0.0-alpha09
    The ui-tooling artifact has not been updated? Should I stick to the previous version?
    d
    • 2
    • 2
  • w

    Wang

    12/21/2020, 9:28 AM
    What are the applicable solutions for asynchronously loading images from remote URLs in Compose’s scroll view? I try to use onCommit to load asynchronously in Image and recompose the UI to show the image. But this way will cause UI freeze when sliding? Do you have any good suggestions?(These codes run in Compose for desktop platform)
    @Composable
    fun NetworkImage(url: String, modifier: Modifier) {
        var imageBitmap by remember { mutableStateOf<ImageBitmap?>(null) }
        imageBitmap?.let {
            Image(bitmap = imageBitmap!!, modifier = modifier, contentScale = ContentScale.Crop)
        }
        onCommit(url) {
            ImageLoader.instance
                .loadUrl(url)
                .listen {
                    if (it.status == Status.success) {
                        imageBitmap = it.content
                    }else{
                        println("image load failed.")
                    }
                }
                .exec()
        }
    }
    c
    c
    • 3
    • 8
  • c

    Cyril Find

    12/21/2020, 11:10 AM
    Hi, How can I remember my
    LazyColumn
    scroll position aver navigating with compose navigation ? I thought hoisting a
    LazyListState
    up to my
    NavHost
    would work but it doesn’t apparently
    a
    m
    +3
    • 6
    • 15
  • j

    John O'Reilly

    12/21/2020, 12:05 PM
    Has anyone come across issue using
    AndroidView
    with
    TabRow
    ....content for other tabs are fine but one with the AndroidView is overlapping tabs....though I could be missing something basic I should be doing with modifiers etc (screenshots in thread)?
    • 1
    • 2
  • k

    Kshitij Patil

    12/21/2020, 1:20 PM
    What's the minimum AS version required to use compose alpha09 ? I tried to use bleeding edge Arctic Fox Canary 3 but found it bugy, fails to show suggestions sometimes so planning to downgrade.
    g
    r
    +5
    • 8
    • 32
  • m

    Marcin Środa

    12/21/2020, 1:25 PM
    Is it possible to use
    LazyColumn
    like
    ScrollableColumn
    with
    reverseScrollDirection = true
    ?
    a
    • 2
    • 2
  • d

    David Attias

    12/21/2020, 2:13 PM
    Hey Guys, I'm struggling finding a way to scroll a
    ScrollableColumn
    to the right offset. I have a
    TextField
    that I want to be visible when the keyboard appears and resize the view. Any idea ?
    s
    • 2
    • 2
  • b

    bodo

    12/21/2020, 3:26 PM
    Hi. Can someone tell me how i can achieve the following shape in a surface. i tried cubic and bezier shapes but no one fits perfect. It is a red background and the bottomLeft and bottomRight cornors should be inverted. Thx
    a
    • 2
    • 2
  • r

    rsktash

    12/21/2020, 10:50 PM
    Hi, how can we check if component is being rendered in AS preview ?
    z
    • 2
    • 2
  • z

    zoha131

    12/22/2020, 3:46 AM
    is there any way to change two different state at the same time without recomposing?
    a
    j
    • 3
    • 11
  • n

    Nana Vong

    12/22/2020, 12:20 PM
    The compose repository hasn't been updated in six days😝
    😂 7
    a
    c
    +5
    • 8
    • 9
  • j

    jim

    12/22/2020, 3:15 PM
    For those of you who are following along from home, we've recently moved active development from
    androidx-master-dev
    to
    androidx-main
    . You will need to check out the new branch if you're building at home and/or just watching the repository for interest. If you are contributing, changes should please be sent to the
    androidx-main
    branch instead of the old branch.
    🎉 17
    🚀 1
    s
    c
    • 3
    • 8
  • k

    Kshitij Patil

    12/22/2020, 3:55 PM
    Is it possible to lock user input to Captial Letters only? capitalisation parameter in Keyboard Options launches keyboard with capital letters but also allows the user to toggle it back to lowercase. Should I use visualization transformation here?
    c
    s
    d
    • 4
    • 9
  • c

    Cyril Find

    12/22/2020, 4:48 PM
    When using
    TextField
    , I randomly get cases where the keyboard doesn’t come up, is it a know issue ? do I need to do something special ?
    👀 5
    s
    k
    +9
    • 12
    • 49
  • k

    Kshitij Patil

    12/22/2020, 6:02 PM
    How can I provide window insets to the main FragmentContainerView? I've TextFields on some of the pages and I want entire app to be lifted up on keyboard shows up. Currently this requires reopening keyboard for the first time for insets to get applied and it only lift the screen till the TextField, all the content below it is being hidden by the keyboard.
    c
    n
    c
    • 4
    • 17
  • b

    Bryan Herbst

    12/22/2020, 6:54 PM
    I’m trying to update to alpha 9, but I’m getting
    This version (1.0.0-alpha09) of the Compose Compiler requires Kotlin version 1.4.21 but you appear to be using Kotlin version 1.4.20 which is not known to be compatible.
    Everywhere my project defines a Kotlin dependency we are using 1.4.21. I can see in my Gradle dependency report that something is forcing Kotlin to 1.4.20 in the
    kolinCompilerClasspath
    configuration, but I don’t see anything that would indicate what is doing that. Any tips on troubleshooting?
    k
    m
    c
    • 4
    • 5
  • l

    Lauren Yew

    12/22/2020, 8:29 PM
    Are 
    Providers
      and 
    Ambients
     like a Dagger inject where I can get a dependency without passing it as a param anywhere? Is there a best practice on their use? https://developer.android.com/reference/kotlin/androidx/compose/runtime/Ambient
    j
    r
    +5
    • 8
    • 33
  • s

    Sam

    12/22/2020, 10:47 PM
    Can someone share insights on how to use
    rememberLazyListState
    with
    LazyColumn
    for a chat interface? JetChat in
    compose-samples
    still uses
    ScrollableColumn
    so it doesn’’t help much, especially in these areas: • How do we smooth scroll to show a new incoming message? Since we only have relative-based
    smoothScrollBy
    instead of
    smoothScrollTo(0f)
    (on
    reverseLayout = true
    ), it’s hard to get to the right spot and
    snapToIndex(0)
    is unnatural • How do we get measurements of the specific message component sizes to make the right relative scrolling calculation? I’ve seen
    chatScrollState.layoutInfo.visibleItemsInfo
    but i’m not sure how to get updates when
    layoutInfo
    changes, sticking it inside
    LaunchedEffect
    doesn’t fire • How do we know when we are getting to the end of the
    LazyColumn
    so that we can fetch older messages and add them to the list? • In the case where new messages are coming in or old messages are being added, how do we maintain existing scroll position without the whole list jumping around?
    d
    a
    • 3
    • 16
  • n

    Neal Sanche

    12/23/2020, 12:16 AM
    Attempting to use a bottom sheet to edit a record in a database. This has a few
    TextField
    in it, and a row of buttons to close, save the record, and delete the record. If I tap into any of the text fields, the keyboard pops up, and pretty much the only decent thing to do at this point is use
    windowSoftInputMode
    set to
    adjustResize
    on the base activity. Now, my problem is, the keyboard stays up after the bottom sheet is collapsed. I found
    AmbientTextInputService
    has a
    hideSoftwareKeyboard
    method, but I don't know where I'm supposed to get the required input session token from? Anyone know? So far, I'm finding text editing to be really complicated in Compose. What am I missing here? I'll drop the code I have into the thread.
    • 1
    • 3
  • b

    bodo

    12/23/2020, 10:41 AM
    Can someone explain me how I can create an animation in a composable function which will be executed every time the composable is called
    @Composable
    fun ShowAnimatedHeader(oldTitle: String, newTitle: String) {
       Box {
          AnimatedVisibility(visible = false, exit = slideOutVertically()) {
             Text(text = oldTitle)
          }
          AnimatedVisibility(visible = true, enter = slideInVertically()) {
             Text(text = newTitle)
          }
       }
    }
    Every time the oldTitle or newTitle change i want to animate the old one out and the new one in. but it is only executed the first time the composable is called
    a
    d
    • 3
    • 9
  • k

    Kirill Grouchnikov

    12/23/2020, 5:24 PM
    What's the magic incantation for a column that is as wide as its widest child, and forces all the children to be that width?
    a
    • 2
    • 3
Powered by Linen
Title
k

Kirill Grouchnikov

12/23/2020, 5:24 PM
What's the magic incantation for a column that is as wide as its widest child, and forces all the children to be that width?
a

Adam Powell

12/23/2020, 5:30 PM
https://developer.android.com/codelabs/jetpack-compose-layouts#9 may have what you're looking for
k

Kirill Grouchnikov

12/23/2020, 5:38 PM
Ah, excellent.
maxIntrinsicWidth
is what I was looking for
The combobox is taking shape 🙂
👍 5
View count: 5