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

    Tgo1014

    03/10/2022, 12:33 PM
    Is there a way already to remove inside padding of TextField?
    s
    • 2
    • 2
  • a

    Alexander Black

    03/10/2022, 5:34 PM
    Anyone else experiencing Android Studio 2021.1.1 Patch 2 freeze on rendering a compose preview? I’m on an M1 Macbook pro which might be part of the problem.
    j
    c
    • 3
    • 4
  • a

    Anudeep Ananth

    03/11/2022, 3:24 AM
    Hi everyone, do you notice Lazy Columns do still have a lot of jank even now if the layout is fairly complex like a social media card… I ve disabled all animations and I still see jank… I feel its because the paging compose version is on alpha : https://developer.android.com/reference/kotlin/androidx/paging/compose/package-summary
    c
    • 2
    • 1
  • a

    aniruddha dhamal

    03/11/2022, 3:30 AM
    Hi, Code coverage with composable functions seem to be off using Jacoco. Any idea? Details in 🧵
    m
    • 2
    • 4
  • a

    Alexander Maryanovsky

    03/11/2022, 6:42 AM
    Is there anything that helps with understanding what caused a recomposition, or why a
    @Compose
    function is not being skipped?
    👀 2
    t
    s
    +2
    • 5
    • 10
  • s

    Stylianos Gakis

    03/11/2022, 11:32 AM
    I had been interested in making a part of my composable App keep the screen awake. Reading though these docs it shows that all the approaches include either an Activity, or services etc. has anyone had to do this before? Any ideas on how to approach it?
    a
    a
    d
    • 4
    • 29
  • n

    nan

    03/11/2022, 1:59 PM
    Hello, I am using
    Layout
    to wrap 2 buttons to create a custom layout, one is
    OutlinedButton
    and another is
    Button
    . But when I pressing on the
    Button
    , the whole custom layout starting flash, it seems the whole Layout keep recompose(I add the log in Layout’s MeasurePolicy lamda and it keeps printing). However, it doesn’t happen if I press on
    OutLineButton
    . How could I avoid this? Thanks. It only happened when I wrap the Button in another Composable, if I just use Button directly(in first level), no issue Is it because when button is pressed, the size change so trigger some recomposition? I found the root cause, if set Button’s
    elevation
    to
    null
    , the problem is gone. But is there method that keep elevation and let Layout works as expected? 🤔
    f
    • 2
    • 4
  • m

    myanmarking

    03/11/2022, 3:35 PM
    I’m trying to debug some piece of code. I narrow it down to this click listener:
    val onItemClicked = { index: Int ->
        listInfoState.animateScrollToItem(index)
    }
    Why would this cause the excess recomposition i am having, without evening triggering the click ?
    m
    t
    • 3
    • 10
  • k

    Kata

    03/11/2022, 3:53 PM
    I am trying to use compose Paging with
    collectAsLazyPagingItems
    . Everything works fine until I scroll to a position which is bigger than the pagingSize and then I call
    invalidate()
    to get the pager data to reload. After this the
    lazyItems
    first only reloads the data for the visible viewport. My problem is that the
    rememberLazyListState()
    is not calculating the right position in this case and the scroll position is wrong. When I delete an item from the first half of the list that is < pagingSize then everything works fine. Is there something like:
    rememberPagingLazyListState()
    or am I making a mistake and it is supposed to work with
    rememberLazyListState()
    ?
    • 1
    • 1
  • c

    chansek

    03/11/2022, 4:45 PM
    How can we show ModalBottomSheet using Compose Navigation? This is how my Modal sheet looks like:
    fun AddressPicker(
        sheetState: ModalBottomSheetState,
        onConfirm: (Address) -> Unit
    ) {
        ModalBottomSheetLayout(
            sheetState = sheetState,
            sheetContent = { AddressForm(onConfirm) }
        ) {}
    }
    Then I added this into my nav graph:
    composable(route = Screen.AddressPickerScreen.route) {
        AddressPicker(sheetState = sheetState) {
           // ...
        }
    }
    And to show it, I used below code:
    navController.navigate(Screen.AddressPickerScreen.route)
    Instead of showing the sheet content, it shows a blank canvas. What am I doing wrong?
    j
    • 2
    • 2
  • l

    lhwdev

    03/11/2022, 4:47 PM
    While testing my code, I got confused about Recomposition. If I have a code like below, then what happens to
    value
    ?
    var value = false
    SomeComposable { item -> // content block
      if(item) value = true
      // etc.
    }
    SomeComposable internally runs for loop. Will it run like normal for loop? Will
    content block
    recompose by itself, making
    value
    inconsistent?
    a
    • 2
    • 3
  • s

    Siyamed

    03/11/2022, 5:02 PM
    Hi all, regarding includeFontPadding related changes b/171394808 in Version 1.2.0-alpha05, we’d love to hear your opinions and the impact on you. If you can give it a try better-er. Please let us know. aosp/1993911 has some screenshot updates showing the difference (it is mostly subtle). This prevents users to do things such as this b/171394808#comment32
    m
    a
    c
    • 4
    • 7
  • r

    Ravi

    03/11/2022, 5:10 PM
    Facing recomposition issue, more in the 🧵
    • 1
    • 2
  • v

    Vlad Makarenko

    03/11/2022, 9:26 PM
    What should I use to achieve this anim?
    Screen Recording 2022-03-11 at 23.23.45.mov
    c
    x
    • 3
    • 4
  • s

    spierce7

    03/11/2022, 9:52 PM
    Is there something special that has to be done to release a compose aar library? We’ve done that privately, but none of the compose functions can be accessed / found. We just end up with build errors.
    j
    a
    • 3
    • 5
  • c

    colintheshots

    03/11/2022, 11:09 PM
    Does anyone have any recommendations for making an AndroidView update a MutableInteractionSource? I want to be able to track focus events from the legacy view in Compose code.
    n
    • 2
    • 1
  • a

    andrew

    03/11/2022, 11:16 PM
    Quick technical question, is there any reason why clickable events being propagated through a box will travel through elements until it reaches a clickable? I.e. my touches seem to phase through views that are above another. This has probably been answered, but figured I’d ask
    c
    • 2
    • 5
  • l

    lesincs

    03/12/2022, 6:00 AM
    Is there a rule of thumb to choose
    Column
    with
    Modifier.verticalScroll()
    or
    LazyColumn
    ? Seems for every scrollable page we can just use
    LazyColumn
    , but the `item {}`makes the development a little bit cumbersome, can I just use
    Column
    for the pages which don’t have infinite scrollable content?
    d
    s
    +3
    • 6
    • 10
  • j

    jasu

    03/12/2022, 7:56 AM
    I’ve compose hierarchy like below, que is NoteListComponent is querying db unnecessarily when I goto detail and come back (because of launchedEffect) is there any way I can ignore unwanted db queries ?
    NoteListComponent(
    notes: List<Note>
    …coupleOfParameters
    ) {
        var searchText by rememberSaveable { mutableStateOf("") }
    
        LaunchedEffect(key1 = searchText) {
            notesViewModel.searchNotes(searchText)
        }
        LazyList(...withParams)
    
    }
    👀 1
    a
    • 2
    • 3
  • n

    Nat Strangerweather

    03/12/2022, 4:59 PM
    I am trying to access my room database viewModel in a Repo file rather than a Composable, because I want to use some data in my MainViewModel. I am getting a mismatch when trying to access the viewModel. What could I be doing wrong? It works absolutely fine when I call it within a Composable. I'm getting this: "Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public inline fun <reified VM : ViewModel> ComponentActivity.viewModels(noinline factoryProducer: (() → ViewModelProvider.Factory)? = ...): Lazy<TypeVariable(VM)> defined in androidx.activity"
    s
    a
    • 3
    • 7
  • c

    chansek

    03/12/2022, 5:07 PM
    My TextField gets hidden behind Keyboard. How do I avoid it? I am able to solve it by below snippet added to my activity.
    android:windowSoftInputMode="adjustResize"
    But if my
    TextField
    is inside a
    ModalBottomSheet
    , then this doesn't work. What should be the fix for this?
    s
    z
    • 3
    • 5
  • r

    ritesh

    03/13/2022, 2:33 AM
    Documentation says - https://developer.android.com/jetpack/compose/lifecycle#skipping All primitive value types, strings and lambdas are
    Stable
    - as they are declared immutable. When declaring a data class or a class which can hold an immutable read-only list, should we mark it as
    Immutable
    as data-structures are not Stable by default? Or compose compiler can infer?
    @Immutable
    data class MyClass {
     val someId:Int,
     val myList:List<SomeClass>
    }
    a
    m
    a
    • 4
    • 11
  • r

    rsktash

    03/13/2022, 4:38 AM
    [SOLVED] I’m using m2 text field. The text is being positioned in wrong position. It must be centered vertically
    r
    • 2
    • 3
  • r

    rsktash

    03/13/2022, 6:06 AM
    [SOLVED] Seems to be the newly built in navigation padding animation has a bug
    telegram_video.mp4
    • 1
    • 3
  • z

    zalewski.se

    03/13/2022, 8:58 AM
    Any idea what would cause a shadow around card composable appear with like a thick black border? In the preview or if I try the same in another app, it looks correct 🤔
    Card(
        shape = RoundedCornerShape(8.dp),
        elevation = 10.dp
    )
    c
    c
    • 3
    • 10
  • z

    ziv kesten

    03/13/2022, 10:29 AM
    Is there anyway to observe
    BottomSheetScaffoldState
    ? i would like to perform an action when its state is
    BottomSheetValue.Collapsed
    I tried using LaunchedEffect but it is not triggered
    val bottomSheetScaffoldState = rememberBottomSheetScaffoldState(
                    bottomSheetState = BottomSheetState(BottomSheetValue.Expanded)
                )
    
                SomeComposableWithBottomSheet(state: BottomSheetScaffoldState)
    
                LaunchedEffect(bottomSheetScaffoldState){
                    if (bottomSheetScaffoldState.bottomSheetState.isCollapsed) {
                        onBackPress()
                    }
                }
    a
    r
    • 3
    • 8
  • t

    theapache64

    03/13/2022, 11:40 AM
    [✅ SOLVED] Subject:
    rememberUpdateState
    I’ve seen most of the
    @Composables
    are using
    rememberUpdateState
    before invoking a lambda. For eg,
    BackHandler
    internally calling
    rememberUpdateState
    on
    onBack
    lambda,
    clickable
    modifier calls on
    onClick
    lambda. Does that mean we should wrap all lambda with
    rememberUpdateState
    before invoking ? 🤔 If that’s the case, why can’t compiler do it for us? #possibly_a_stupid_question
    👍 1
    a
    r
    • 3
    • 15
  • c

    Colton Idle

    03/13/2022, 5:29 PM
    This is bad right?
    @Composable
    fun SomeScreen(
        viewModel: SomeScreenViewModel = hiltViewModel(),
        someIdINeed: String = ""
    ) {
        viewModel.init(someIdINeed)
        MyActualScreenContent()
    }
    The viewModel.init(id) should go inside of a remember{}? Or is it better to do LaunchedEffect(Unit)? edit: I almost wonder how viable it'd be to create a lint rule or something that would flag this sort of stuff in a composable. The above code was in our codebase for like 3 months before i noticed it just now.
    👍 1
    a
    h
    +2
    • 5
    • 15
  • s

    S.

    03/13/2022, 8:57 PM
    How do you achieve a keyboard that only allows numeric input? no dots, dashes, only 0-9
    KeyboardType.Number
    still allows special characters while
    android:inputType="number"
    doesn't
    r
    a
    • 3
    • 8
  • r

    Rafiul Islam

    03/14/2022, 7:57 AM
    Should I use LazyVerticalGrid for production code? or achieve the same result with LazyColumn and Row as suggested.
    s
    a
    • 3
    • 6
Powered by Linen
Title
r

Rafiul Islam

03/14/2022, 7:57 AM
Should I use LazyVerticalGrid for production code? or achieve the same result with LazyColumn and Row as suggested.
s

Stylianos Gakis

03/14/2022, 11:40 AM
Use it but be prepared to change your code if the APIs change in whatever way. That’s basically what that annotation tells you. It should work fine, but the API is subject to change in backwards-breaking ways.
a

Albert Chang

03/14/2022, 12:41 PM
Btw it's already stable in the latest alpha.
➕ 3
r

Rafiul Islam

03/14/2022, 1:16 PM
Actually it's for a client maybe I won't get the chance to change it later.
s

Stylianos Gakis

03/14/2022, 1:22 PM
If you never update the compose version, then it would never be a problem anyway. But besides that, as Albert said, the API is settled in the latest Alpha. Idk if it’s changed from the version you’re using to that alpha, but if not then the API problem doesn’t exist either. One could update compose version and have it still compile just fine.
r

Rafiul Islam

03/14/2022, 1:28 PM
Thanks. It's a relief then. It's highly likely that compose version won't update either. So if it works now it will keep working right? By the way should I use the alpha version for production?
s

Stylianos Gakis

03/14/2022, 1:34 PM
That’s a decision you have to make for yourself. The Alphas are noted as alphas mainly for API stability, and not quality stability afaik, but you’re always putting yourself in the risk that due to less people using it, more subtle bugs may have slipped through. While with a stable version you know that a ton more people are using it, hence probably safer.
View count: 4