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

    Colton Idle

    04/20/2022, 7:03 PM
    Version 1.2.0-alpha08 is out! • Update to Kotlin 1.6.20! • New experimental
    LazyLayout
    API is introduced. This allows you to build your own components like
    LazyColumn
    of
    LazyVerticalGrid
    . Note that the API is in its early stages and can be changed in the future releases • Bunch of updates to Paragraph, pointer input, Fonts Material 3 updates •
    material3-window-size-class
    is a new library that provides support for window size classes: a set of opinionated viewport breakpoints for you to design, develop, and test resizable application layouts against. • Lots of little updates
    🎉 19
    👀 2
    :jetpack-compose: 6
    :kotlin-intensifies: 5
    t
    t
    +4
    • 7
    • 11
  • t

    Tolriq

    04/20/2022, 7:11 PM
    For the record the new material3 a10 require the 1.2 alpha08 compiler
    👍 1
    • 1
    • 1
  • a

    andrew

    04/20/2022, 8:11 PM
    Immediately encountering
    Inconsistency between the count of nodes tracked by the state (0) and the children count on the SubcomposeLayout (1). Are you trying to use the state of the disposed SubcomposeLayout?
    in all of my lazy lists after scrolling after upgrading to alpha 08
    ➕ 2
    a
    r
    m
    • 4
    • 8
  • t

    Tolriq

    04/20/2022, 8:15 PM
    ^^ mostly same posted before to ask for possible cause to build a repro but no answers. For me it seems to only be the lazy lists that have multiple item {} calls, the one with only 1 items{} does not seems to trigger that.
    a
    • 2
    • 1
  • b

    bbade_

    04/20/2022, 8:45 PM
    Is there any way to get more details about what android studio is doing when generating previews? They are VERY slow, and i’m trying to figure out if there’s anything i can do to speed the process up in my codebase
    💯 5
    👀 1
    c
    • 2
    • 4
  • b

    Ben Trengrove [G]

    04/20/2022, 9:53 PM
    For the LazyLayout crash, do you have a sample that reproduces it or is it just happening in your app?
    a
    a
    • 3
    • 18
  • j

    Jan

    04/20/2022, 10:30 PM
    Hey this should create a Column where each item is a row with 4 thumbnails:
    val files = remember { File(parent).listFiles()!!.toList().chunked(4) }
        LazyColumn {
            items(files.size) {
                Row {
                    files[it].forEach { video ->
                        Thumbnail(video, size)
                    }
                }
            }
        }
    The problem is that the thumbnail thing takes a bit to load however the lazy column either calls the thumbnail method all at once or I'm doing something wrong because it's not loading. If I only take 4 of files it loads a few seconds and its fine
    a
    z
    • 3
    • 4
  • b

    brabo-hi

    04/21/2022, 12:06 AM
    Hi all, am i the only one who is having issue with the preview when using
    androidx.activity:activity-compose:	1.6.0-alpha01
    ?
    i
    • 2
    • 5
  • t

    the great warrior

    04/21/2022, 3:32 AM
    hi guys, I am wondering if there is any library or approch that makes implementing compose navigation back stack for multiple screens inside activity easy
    i
    c
    • 3
    • 2
  • h

    Harold Scissors

    04/21/2022, 5:25 AM
    Hi folks :android-wave: Question about smart recompostion. If I have a composable function like:
    @Composable
    fun CustomView(myObject: MyObject) { //some Compose UI }
    If
    MyObject
    isn't marked
    @Stable
    will this method be recomposed regardless if the values of
    MyObject
    have not change?
    b
    a
    +3
    • 6
    • 14
  • j

    jermainedilao

    04/21/2022, 9:06 AM
    Hey! Does anyone have/know a public github repo that uses Jetpack Compose + Coroutines Flow AND contains Android Tests? I’m just starting with compose and I’m looking for inspirations 🙂
    ➕ 1
    j
    f
    • 3
    • 4
  • m

    Mor Amit

    04/21/2022, 9:40 AM
    Hey all, I’m trying to do a bounce animation to an image. This image is placed inside a box. The box is the Composable that handles the click and should start the animation on the image inside it. I created the
    bounce
    function, an extension of Modifier. The
    bounce
    function receives a
    shouldBounce
    boolean that indicates if I should start the animation. I wonder if there is a better way to do that and move the
    shouldBounce
    boolean into the Modifier. With my current implementation, I need to define a
    shouldBounce
    boolean in every place that wants to use my bounce function. Maybe there is a way to catch the click event on both Box and Modifier? I attached some code examples in the first reply
    :thread-please: 1
    🔥 1
    m
    c
    z
    • 4
    • 18
  • j

    jean

    04/21/2022, 10:38 AM
    How can I animate a Box to increase its size and revert the animation to its original size right after? I did try to use
    animateFloatAsState
    with 2 iterations but when the animation ends, the size of the box jumps to the
    targetValue
    z
    • 2
    • 12
  • d

    dimsuz

    04/21/2022, 12:31 PM
    If I have a
    Row
    and if a sum width of all of its children is less than
    screenWidth
    I want to use
    .weight(1)
    for them. Otherwise I want to use
    .horizontalScroll()
    on the
    Row
    . Is there a nice way to achieve this? I thought about
    SubcomposeLayout
    instead of
    Row
    but I'm not sure, because I need to also manipulate
    Modifier
    in this case (for scrolling)
    f
    z
    • 3
    • 11
  • n

    Nabeel

    04/21/2022, 12:40 PM
    Is there any way to achieve this kind of ui?
    LazyColumn() {
    Card() { 
          item{
              //Some ui
    }
    items(myItems) { item ->
             // item here
          }
      }
    }
    a
    s
    c
    • 4
    • 10
  • h

    humbledroid

    04/21/2022, 1:14 PM
    One of the problem that I am facing is with
    DropDownMenu
    , that it uses Column, thus cannot have huge number of items, without allowing it to populate all items at once, and this will lead to frame drop and crashes.
    DropDownMenu
    as of today cannot leverage
    LazyColumn
    as intrinsic size for
    Subcomposelayouts
    is not yet supported, and fixed height width cannot be given to the
    LazyList
    in
    DropDownMenu
    because of the use case. The use case is to show list of countries and choose one of them, and for that I am using the
    DropDownMenu
    but as the size of countries list is enough to make it draw after a few frame drop. I found an issues similar to this, ISSUETRACKER and is closed as it works as intended, because this is not meant for long lists, i guess. maybe a time for
    LazyDropDownMenu
    I tried replacing the
    Column
    with
    LazyColumn
    but that would not work because of the intrinsic measurements , and it works perfectly fine, when the
    height
    and
    width
    is supplied via modifier to
    LazyColumn
    .
    👍 1
    👍🏽 1
    a
    a
    • 3
    • 3
  • n

    Naga

    04/21/2022, 5:40 PM
    Hi Folks, Need some guidance on 1. Whats the right patterns to pass parameters to Composable functions, if they are related and can be grouped. Compose API guidelines address this with
    Jetpack Compose framework and Library development SHOULD declare hoisted state types as interfaces instead of abstract or open classes if they are not declared as final classes
    at https://github.com/androidx/androidx/blob/androidx-main/compose/docs/compose-api-guidelines.md#default-policies-through-hoisted-state-objects It is understood that keeping Extensibility of hoisted type in mind, it’s better to expose Interface instead of concrete types, but if for a given environment if Extensibility is not a priority can we use
    data
    class a parameter to composables? is this encouraged?
    data class BarState {
        val name: String
        val avatarUrl: String
    }
    
    @Composable
    fun Bar(barState: BarState) {
    If its okay to use as above, Again its understood that we can’t have access to LocalContext or Theme objects inside data class, an easy workaround is
    data class BarState(
        val name: String
        val avatarUrl: String
        val contentColor: @Composable () -> Color = {
            MaterialTheme.colors.primary
        }
    )
    This makes the
    BarState
    data class mutable, hence the input to composable too, is this pattern still has any value? Have observed in the forum to avoid ever using
    [Mutable]State<T>
    in a parameter list to composable
    getFoo: () -> Foo
    is always going to be a more flexible parameter than
    foo: State<Foo>
    2. With this , if i can pas a function as a parameter to composable, why can’t i use same inside a data class? Any feedback/ inputs will be greatly helpful.
    m
    a
    • 3
    • 15
  • m

    Mehdi Haghgoo

    04/21/2022, 7:19 PM
    Any easy way to draw text in Compose? I wish I could draw text as I do drawCircle(), drawRect(), etc. in DrawScope.
    s
    c
    +4
    • 7
    • 10
  • l

    Lilly

    04/21/2022, 8:38 PM
    Can someone tell me what is wrong here:
    java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed.
    ...
    val scrollState = rememberScrollState()
    
    Column(
    	modifier = Modifier
    		.fillMaxHeight()
    		.verticalScroll(scrollState)
    ) {
        Card(modifier = Modifier.fillMaxWidth())
        Card(modifier = Modifier.fillMaxWidth()) {
            LazyVerticalGrid() {}
        }
    }
    The parent is the content slot of
    BottomSheetScaffold
    . I know it has to do with the
    LazyVerticalGrid
    , but both Cards measure the height by its content so I don't understand what the problem is. EDIT:
    Card(modifier = Modifier.fillMaxWidth().weight(1f, false))
        Card(modifier = Modifier.fillMaxWidth().weight(1f, false)) {
            LazyVerticalGrid() {}
        }
    Applying
    weight
    on both Cards solves the exception but now the
    LazyVerticalGrid
    is scrollable. I would like to wrap content height of the latter
    Card
    , is this possible?
    c
    • 2
    • 15
  • s

    Sean Proctor

    04/22/2022, 1:32 AM
    What's the deal with the keyboard in compose 1.2? It used to be that navigating to a new screen with no textfield would hide the keyboard. That no longer appears to happen. Did I miss something or do I now need to track whether the keyboard should be shown?
    a
    • 2
    • 2
  • j

    Jaime

    04/22/2022, 3:57 AM
    Hello everyone, update to version 1.2.0-alpha08 of compose, I have an error in a lazyColumn when scrolling down, this does not happen to me in version 1.2.0-alpha07
    java.lang.IllegalArgumentException: Inconsistency between the count of nodes tracked by the state (0) and the children count on the SubcomposeLayout (5). Are you trying to use the state of the disposed SubcomposeLayout?
                                                                                                  	at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.makeSureStateIsConsistent(SubcomposeLayout.kt:514)
                                                                                                  	at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:391)
    r
    • 2
    • 1
  • y

    Yves Kalume

    04/22/2022, 10:31 AM
    That's why i was asking how to get lazycolumn or lazyrow progression percentage. My animation isn't very smooth
    device-2022-04-20-182113.mp4
    😯 2
    c
    • 2
    • 2
  • r

    Ryan Simon

    04/22/2022, 12:36 PM
    Hey all :android-wave: , has anyone had luck getting a
    HorizontalPager
    to work inside of a
    LazyColumn
    ? I've got a rather involved screen that has multiple
    HorizontalPagers
    for images and for tabs. All of the content should be vertically scrollable. Screenshot in thread.
    c
    c
    • 3
    • 7
  • n

    nuhkoca

    04/22/2022, 2:34 PM
    Hello, how one can define a multiple derivedStatedOf? I have a code like below but they are called constantly when I log and recomposition happening. As far as I understand correctly, recomposition should only happen when
    isPageTitleReached
    and
    isContentScrolled
    changed, right?
    val isPageTitleReached by derivedStateOf {
        remember {
            lazyListState.firstVisibleItemScrollOffset > 500
        }
    }
    val isContentScrolled by derivedStateOf {
        remember {
            lazyListState.firstVisibleItemScrollOffset > 600
        }
    }
    👀 2
    ✅ 1
    m
    m
    t
    • 4
    • 15
  • m

    mattinger

    04/22/2022, 2:49 PM
    Does anyone know if the accompanist navigation libraries support combining the animated and bottom sheet navigators? Looking at the code would suggest so:
    @ExperimentalAnimationApi
    @Composable
    fun rememberAnimatedNavController(
        vararg navigators: Navigator<out NavDestination>
    ): NavHostController {
        val animatedNavigator = remember { AnimatedComposeNavigator() }
        return rememberNavController(animatedNavigator, *navigators)
    }
    I assume i would pass the resolve of a rememberBottomSheetNavigator() call?
    c
    i
    • 3
    • 6
  • t

    tad

    04/22/2022, 9:04 PM
    I get into a morass whenever I implement a TextField where the input is parsed to some other value type (e.g. LocalDate). Like, do I hoist the parsed value and hide the text input as internal to the composable adding the TextField?
    b
    • 2
    • 4
  • l

    Lilly

    04/23/2022, 3:01 PM
    Does
    TabRow
    has swipe behavior for its content? I'm wondering because its documentation says yes but it doesn't has it actually.
    To navigate between fixed tabs, tap an individual tab, or swipe left or right in the content area.
    a
    • 2
    • 3
  • r

    raghunandan

    04/23/2022, 3:16 PM
    How to achieve @ mentions like twitter and facebook similar to https://github.com/linkedin/Spyglass using compose. Any suggestions or ideas?
    a
    n
    • 3
    • 17
  • s

    Shakil Karim

    04/23/2022, 5:04 PM
    Hello everyone, i am showing multiple bottomSheet using BottomSheetScaffold but for closing the sheet i am creating a property like this, Is it fine to define properties like
    closeSheet
    and
    openSheet
    inside Composable because Main can recompose very often?
    @Composable
    fun Main() {
    
    val closeSheet: () -> Unit = {
        scope.launch {
            scaffoldState.bottomSheetState.collapse()
        }
    }
    
    val openSheet: (BottomSheetScreen) -> Unit = {
        currentBottomSheet = it
        scope.launch {
            delay(100)
            scaffoldState.bottomSheetState.expand()
        }
    }
    
    if (scaffoldState.bottomSheetState.isCollapsed)
        currentBottomSheet = null
    
    }
    a
    j
    • 3
    • 2
  • l

    Lilly

    04/23/2022, 8:36 PM
    [SOLVED] Is it correct behavior that the shadow of the Card is cut off at the top edge? You might have to zoom-in to notice it.
    Column(modifier = Modifier
        .padding(24.dp)
        .fillMaxSize()
        .verticalScroll() // this causes the clipping
    ) {
        Card(elevation = 16.dp) {}
    }
    b
    • 2
    • 10
Powered by Linen
Title
l

Lilly

04/23/2022, 8:36 PM
[SOLVED] Is it correct behavior that the shadow of the Card is cut off at the top edge? You might have to zoom-in to notice it.
Column(modifier = Modifier
    .padding(24.dp)
    .fillMaxSize()
    .verticalScroll() // this causes the clipping
) {
    Card(elevation = 16.dp) {}
}
b

bohregard

04/24/2022, 12:24 AM
It looks like it’s clipping to the padding of the parent? I tried to replicate it with a fresh project but I couldn’t get it to repo.
setContent {
    CardTestTheme {
        // A surface container using the 'background' color from the theme
        Surface(
            modifier = Modifier.fillMaxSize(),
            color = MaterialTheme.colors.background
        ) {
            Column(modifier = Modifier.padding(24.dp).fillMaxSize()) {
                Card(elevation = 16.dp) {
                    Box(modifier = Modifier.padding(12.dp)) {
                        Text(
                            style = MaterialTheme.typography.h5,
                            text = "Connection and Communication"
                        )
                    }
                }
            }
        }
    }
}
This is on a phone running Android 12 using compose version 1.1.1
l

Lilly

04/24/2022, 12:42 AM
@bohregard Thanks for your investigation. I missed something. Can you add .
verticalScroll(rememberScrollState())
to the parent Container. I just figured out that it only happens when this Modifier is set.
I have adjusted my initial post
b

bohregard

04/24/2022, 12:45 AM
So it’s an issue of modifier order then
you want your vertical scroll modifier to come before the padding modifier since they apply in the order you write them
Moving that up should fix that issue
l

Lilly

04/24/2022, 12:48 AM
You are an awesome cat bohregard <3
b

bohregard

04/24/2022, 12:49 AM
:cat-on-keyboard:
❤️ 1
View count: 5