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

    Odin

    10/20/2022, 8:11 PM
    Hi 👋 😄 Does anyone know if it is possible to do a linear transformation on the canvas in jetpack compose? So what I mean is mapping each point (u, v) on for instance an arch to (x, y) based on a function f so that f(u, v) = (x, y). Is that possible? 🙂 Is there any good docs on how to do that if it is possible? 🙂
    a
    r
    • 3
    • 3
  • s

    smithc42

    10/20/2022, 9:43 PM
    Hi folks, I'm trying to figure out how to change text color based on the
    initialState
    value within
    AnimatedContent
    . Using the AnimatedContent example from the Android docs which slides number up/down based on the previous
    initialState
    , I've tried updateTransition along with
    animateColor
    but I can't find a way to change the text color based on the previous value. Am I missing something obvious here? 🤔
    r
    d
    • 3
    • 6
  • p

    Piotr Krzemiński

    10/21/2022, 6:19 AM
    is there a live, online showcase of available Compose Multiplatform components, like we have for Kotlin MUI?
    s
    m
    • 3
    • 3
  • j

    Jasmin Fajkic

    10/21/2022, 9:37 AM
    Hello there. We have main app navigation inside the scaffold. Scaffold provide padding values and we pass this padding to app navigation. How to make on clean way that screens that does not need this padding just exclude it? Ok I can make main viewmodel and control this behaviour but this sounds somehow wrong. Any advice maybe?
  • f

    FunkyMuse

    10/21/2022, 11:06 AM
    Hey guys, does anyone know if there's an official API support or something that can enable fast scrolling for a LazyColumn?
  • k

    Kev Thompson

    10/21/2022, 11:12 AM
    Hi. we are using ExposedDropdownMenuBox and ExposedDropdownMenu to display a list of numbers to select from.. Does anyone know if there is a way to have a scrollbar with this set up?
  • o

    oday

    10/21/2022, 12:11 PM
    why would this not work
    @Composable
    fun Chip(
        label: String,
        enabled: MutableState<Boolean>,
        onClick: () -> Unit,
    ) {
        val (selected, setSelected) = enabled
    
        val chipColor =
            if (selected) MaterialTheme.colors.Action else MaterialTheme.colors.ForegroundMuted
    
        Surface(
            shape = RoundedCornerShape(15.dp),
            color = chipColor.copy(alpha = 0.2f),
            border = BorderStroke(
                width = 1.dp, color = chipColor
            ),
            modifier = Modifier
                .toggleable(
                    value = selected,
                    enabled = true,
                    onValueChange = setSelected
                )
                .clickable {
                    onClick()
                },
    but this would
    modifier = Modifier
                .clickable {
                    onClick()
                    setSelected(!selected)
                },
    Thanks
    r
    m
    • 3
    • 6
  • c

    czuckie

    10/21/2022, 4:35 PM
    I've got the following:
    val rotation by animateFloatAsState(
            targetValue = if (state) 360.0f else 0f, 
            animationSpec = if (state) InfiniteRepeatableSpec(tween(durationMillis = 500, easing = LinearEasing)) else snap())
    Which I use to rotate an image of a fan when the fan is on, and when it is off, it rotates to a final stationary position. However if the composable first appears in an on state, the animation will not start. How should I handle this?
    j
    • 2
    • 2
  • l

    Lisandro Di Meo

    10/21/2022, 4:51 PM
    Why when I navigate from screen A to screen B, screen A still recomposes? For example
    composable(A){
       // other stuff
       ScreenA( navHostController, ..., onNavigateToB = { navHostController.navigate(B) } ) 
       // after onNavigateToB executes, it recomposes and re-renders ScreenA 
    }
    composable(B){
       ScreenB( ... )
    }
    i
    • 2
    • 8
  • a

    Andrea

    10/21/2022, 8:56 PM
    Hello everyone, I have a suggestion to ask you regarding LazyColumn and nested lists. Nested scrollable is not allowed, but what if I wanted to have a list of cards (probably 10) where each one has an expanded collapse state that shows / hides an internal list? For example, in this codelab each card has the behaviour I am looking for, but it shows / hides a simple composable. A solution is adding an internal column but would it impact the performance if there are a lot of items? Another idea was using item (for the header) and items when expanded, but I am not sure if I can surround them with a card since we are in the LazyListScope which is not composable. Thanks!
    j
    • 2
    • 2
  • z

    zt

    10/21/2022, 10:19 PM
    How can I make editing a text field use incognito mode on the keyboard? similar to how it works on chrome incognito mode. KeyboardOptions doesn't look like it has an option, is it not supported?
  • z

    zt

    10/22/2022, 1:13 AM
    Using AnimatedContent, can I somehow get the exiting content to overlap the entering content? instead of the opposite
    s
    • 2
    • 1
  • g

    Giorgi

    10/22/2022, 12:56 PM
    Hi guys, I found a project that uses compose on the web directly without DOM API. https://github.com/mykola-dev/Tetris Where can I find docs showing how to do the same? Im unable to figure out what mykola-dev exactly do to make compose work on the web
    j
    z
    s
    • 4
    • 3
  • s

    ste

    10/22/2022, 2:15 PM
    I'm using
    LazyLayoutPrefetchState
    in a custom
    LazyLayout
    to prefetch the previous page and the next one (e.g. in "A, B, C, D, E", I prefetch A and C). However, pages can be swapped (e.g. "A, B, E, C, D"). How can I handle such thing? How can I tell the
    Prefetcher
    the item at index 2 has changed? Is
    LazyLayoutItemProvider
    involved at all?
    a
    • 2
    • 4
  • j

    Jasmin Fajkic

    10/22/2022, 2:59 PM
    Stupid question and very basic probably. When I navigate from screen A to screen B I can still get back to screen A even if I use
    inclusive=true
    . Code in 🧵
    • 1
    • 2
  • s

    Sudhir Singh Khanger

    10/22/2022, 4:20 PM
    What is the term called for items in a LazyLayout(LazyRow/LazyColumn) which are not needed? For example, you have a long list where you have items which are
    visible
    , which may be shown imminently (
    prefetched
    ), and items down the line which are far away in the list. Which state the last items are in?
    j
    • 2
    • 1
  • s

    Sudhir Singh Khanger

    10/22/2022, 4:25 PM
    I want to trigger a callback when a
    LazyColumn
    item becomes visible for only once. It shouldn't trigger if a user moves up and down the list. The problem I am facing is that irrespective of which side effect I use any time a Composable from down the list becomes visible, it seems, starts a new composition which means the side effect gets triggered when a user moves up or down the list. Is there a way to avoid this situation? I had asked my question here on SO. So far, the only way to handle this situation for me would be holding a variable in the data class (
    isSeen: Boolean
    ).
    j
    • 2
    • 1
  • a

    Aaron Waller

    10/22/2022, 6:03 PM
    I uploaded my first jetpack compose app and I’m getting a lot of crashes that I can’t reproduce on my devices.
    Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.ViewGroup.getChildAt(int)' on a null object reference
    at androidx.activity.compose.ComponentActivityKt.setContent (ComponentActivityKt.java:264)
      at com.censored.censored.presentation.MainActivity.onCreate (MainActivity.java:264)
    Full crash in thread -> MainActivity line 264 points to a DrawerItem: (first line is 264)
    DrawerItem(
        imageDrawable = R.drawable.gold,
        title = "Text"
    ) {
        uriHandler.openUri("<https://google.com>")
    
    }
    Someone has an idea how I can fix it?
    z
    • 2
    • 3
  • z

    zt

    10/22/2022, 11:41 PM
    How can I make my navigation bar go off screen when scrolling similar to how top app bar has it?
  • z

    zt

    10/23/2022, 3:42 AM
    I have a LazyRow, how can I make the items kind of like a stack, where at the start its a little overlap and at the end its more overlap
  • b

    Bagadeshkumar R

    10/23/2022, 4:39 AM
    Hey Guys, Any idea on how to change text colour without recomposing the composable? Think google put out an example to use drawBehind to change the background. Since differing font colour change until the draw phase is not there(At least that I know of). Any directions on this?
    h
    • 2
    • 2
  • i

    Ilan Sasportas

    10/24/2022, 8:10 AM
    Hello ! I have a
    NavigationBar
    in my Compose code, and I’m trying to have a navigation stack for each tab (so that when I change tabs, my stack for that tab is restored). What I have seen in the docs is that this all feature is build around routes. And my problem is, some tabs of the bottom bar have the same route showing different data. Are you aware of any way to make this a bit more dynamic ? Thanks for your help !
  • r

    Rihards

    10/24/2022, 8:23 AM
    Hi! I have an issue with BottomSheetDialogFragment() - when I try to set it’s view as Jetpack Compose then I’m not able to set the necessary theme to the fragment by using
    getTheme
    function in the fragment which is working in other places in the app where .xml is being used. How can I get rounded bottom sheet corners in this situation?
  • r

    Rafs

    10/24/2022, 9:28 AM
    Is it possible to apply more than one
    horizontalArrangement
    to the children of a
    Row
    . I want to use a combination of
    Arrangement.spacedBy()
    and
    Arrangement.Center
    to center the children in the row with even spacing. I can only do one at the moment.
    f
    • 2
    • 2
  • s

    Slackbot

    10/24/2022, 9:29 AM
    This message was deleted.
    z
    • 2
    • 2
  • s

    sunnat629

    10/24/2022, 2:28 PM
    Hi, How can I use
    elevation
    in
    TopAppBar
    of Material3? Thanks.
  • l

    langara

    10/24/2022, 2:38 PM
    Hi, does it make any sense to try to implement sth like:
    @Composable
    fun <T> delayedStateOf(init: T, delayMs: Long = 200, calculation: () -> T): State<T> {
        ....
        val derived = derivedStateOf { if(someCacheNotOutdated) useCache else calculation()... } // FIXME: correct conditional control of reads (subscriptions)
        ....
        return derived
    }
    So this
    delayedStateOf
    would be a bit lazy updating, so I can use it as input for some low priority part of UI. Maybe better idea would be to use
    SnapshotStateObserver
    directly - I experimented with it a bit, but I have other issues with that Or maybe only reasonable solution is to go even lower level and play with snapshots directly? (like
    snapshotFlow
    does)
    z
    s
    • 3
    • 8
  • v

    Vinay Gaba

    10/24/2022, 5:32 PM
    Really happy about the introduction of BOM in Compose. Seems like a no-brainer feature for everyone to use - https://developer.android.com/jetpack/compose/setup#using-the-bom
  • s

    ste

    10/24/2022, 7:19 PM
    Are
    LocalLifecycleOwner.current
    and
    LocalSavedStateRegistryOwner.current
    guaranteed to be
    Activity
    ?
  • j

    Jorge Domínguez

    10/24/2022, 8:34 PM
    has anybody checked the experimental
    LazyHorizontalStaggeredGrid
    in
    androidx.compose.foundation
    ? I'm getting the following exception which seems to indicate that I need to pass in a fixed height (and indeed that fixes it) but it doesn't sound right since its height should depend on the children.
    java.lang.IllegalArgumentException: LazyHorizontalStaggeredGrid's height should be bound by parent.
    my implementation looks like this:
    LazyHorizontalStaggeredGrid(
        modifier = Modifier.fillMaxWidth(),
        rows = StaggeredGridCells.Fixed(3)
    ) {
        items(showcaseFeatures) {
            FeatureChip(name = it)
        }
    }
    a
    s
    k
    • 4
    • 5
Powered by Linen
Title
j

Jorge Domínguez

10/24/2022, 8:34 PM
has anybody checked the experimental
LazyHorizontalStaggeredGrid
in
androidx.compose.foundation
? I'm getting the following exception which seems to indicate that I need to pass in a fixed height (and indeed that fixes it) but it doesn't sound right since its height should depend on the children.
java.lang.IllegalArgumentException: LazyHorizontalStaggeredGrid's height should be bound by parent.
my implementation looks like this:
LazyHorizontalStaggeredGrid(
    modifier = Modifier.fillMaxWidth(),
    rows = StaggeredGridCells.Fixed(3)
) {
    items(showcaseFeatures) {
        FeatureChip(name = it)
    }
}
a

Andrey Kulikov

10/24/2022, 10:58 PM
cc @shikasd
s

shikasd

10/25/2022, 2:30 PM
For now it works the same way as
LazyGrid
does, taking up the whole height (in horizontal orientation) We are looking into adding a way to define fixed child height and size the grid and staggered grid dynamically
j

Jorge Domínguez

10/25/2022, 3:44 PM
so I must either provide a fixed height or place the
LazyHorizontalStaggeredGrid
inside a parent with a fixed height?
s

shikasd

10/25/2022, 4:01 PM
preferably yes 🙂
k

Karthick

11/07/2022, 6:10 AM
Lazy and Recycler view to work properly height or width need to be constrained/fixed otherwise lazy/recycling functionality won’t work. I think in compose they made it stricter.
View count: 8