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

    chansek

    03/22/2022, 7:30 PM
    Getting an issue in compose navigation which was working fine in
    2.4.0-alpha04
    Whenever I do
    navController.popBackStack()
    , I see the behavior attached in the video. For now the fix is by downgrading the navigation version.
    "androidx.navigation:navigation-compose:2.4.0-alpha04"            // Working fine
    
    vs
    
    "androidx.navigation:navigation-compose:2.4.0-alpha05" or above   // Doesn't work
    Is there any way to fix it up or I have to wait until it is being fixed by Google?
    This behavior is found till 2.5.0-alpha03
    Looks like this commit caused the issue:
    https://android-review.googlesource.com/c/platform/frameworks/support/+/1750073
    recording 01.mp4
    i
    • 2
    • 19
  • c

    Chris Johnson

    03/22/2022, 10:45 PM
    :android-wave: Is there a way to determine when a key has changed and when that is true run certain blocks of code in a composable? For example, I want to run a certain block of code only when
    scrollState.isScrollInProgress
    changes from false to true or true to false. I don't want to use a LaunchedEffect with a key to avoid creating a new CoroutineScope everytime someone starts/stops scrolling.
    f
    z
    +3
    • 6
    • 18
  • i

    iamraghavawasthi

    03/23/2022, 5:39 AM
    Hey I am trying to achieve blur but on documentation it says it is supported only on Android 12 and above. Any clue on how to make it backward compatible
    a
    f
    • 3
    • 3
  • r

    ritesh

    03/23/2022, 6:56 AM
    Can compose infer stability of a
    sealed
    class ?
    sealed class MyClass {
      object A :  MyClass()
      data class SomeClass(val value:String): MyClass()
    }
    g
    m
    z
    • 4
    • 28
  • b

    Benjamin Deroche

    03/23/2022, 9:44 AM
    What unit of measure use the
    Canvas
    function
    drawCircle
    ? If I draw a circle with a radius of 72 and a
    FloatingActionButton
    with a size of
    72.dp
    the circle end up bigger than the button.
    Box(
        modifier = Modifier.size(120.dp).align(Alignment.TopCenter)
    ) {
        Canvas(
            modifier = Modifier.align(Alignment.Center)
        ) {
            drawCircle(
                color = MaterialColor.Red400,
                radius = 72f,
            )
        }
        FloatingActionButton(
            modifier = Modifier
                .align(Alignment.Center)
                .size(72.dp),
            backgroundColor = MaterialColor.Orange400,
            onClick = {}
        ) {
            Icon(
                imageVector = Icons.Default.ArrowUpward,
                contentDescription = "!"
            )
        }
    }
    f
    • 2
    • 2
  • t

    Tobias Gronbach

    03/23/2022, 10:24 AM
    How can I avoid recomposition of certain areas of a screen? In my example I use an AndroidView (to show diagrams) and also I display some Dialogs depending on the ScreenState. Everytime a dialog is shown or hidden the AndroidView gets recomposed. How can I avoid it? Is it possible to scope recomposition only to specific states?
    m
    r
    • 3
    • 36
  • o

    Orhan Tozan

    03/23/2022, 12:13 PM
    With @Preview, what is the best way to debug/log values?
    👀 1
    ➕ 1
    c
    c
    • 3
    • 16
  • f

    Francois Morvillier

    03/23/2022, 3:21 PM
    Hi, is there a way to find out what triggered a recomposition?
    r
    m
    m
    • 4
    • 4
  • g

    gpaligot

    03/23/2022, 4:39 PM
    Hi here! I’m building a design system with compose and my designers want to create a disabled button where an alpha is applied on the entire component but where the transparency applied on the text doesn’t show the background behind. Because a button with compose is a surface and a text in top of it, I would like to know if it is something possible or not? 🤔 You can find the Figma visual and the Compose preview to show the current difference between the design specification and the compose implementation Thanks in advance if someone have an idea!
    k
    s
    c
    • 4
    • 5
  • m

    myanmarking

    03/23/2022, 6:06 PM
    Why this is not working:
    background(
        brush = brush
    ).graphicsLayer(
        shape = shape,
        clip = true
    )
    It only works when i move the shape to be a background param. Why ? I need a dynamic shape. Graphics Layer better suited
    z
    k
    • 3
    • 9
  • j

    julioromano

    03/23/2022, 6:21 PM
    Is it possible to specify the padding amount as a percentage of a composable’s width/height?
    z
    • 2
    • 14
  • v

    Vinay Gaba

    03/23/2022, 8:17 PM
    I was working on a custom composable using
    Layout
    and noticed that modifiers like weight weren't being propagated through the constraints inside the
    MeasurePolicy
    . I'm wondering what's the best way to handle this so I don't have to manually hardcode weight calculations when I place my composables there. Adding a code snippet in the thread.
    z
    • 2
    • 20
  • c

    Colton Idle

    03/23/2022, 9:11 PM
    Compose Version 1.2.0-alpha06 is out today! Some release notes that I found interesting. • A bunch of focus related stuff!!!! • TextFields will now be kept above the keyboard when they are focused and the keyboard is shown, when inside a non-lazy scrollable and the soft input mode is
    ADJUST_RESIZE
    . WOOOOOOOOOOOOOOOOOO Thanks @Zach Klippenstein (he/him) [MOD] 😄 • Added
    RequestFocus
    semantics action to request focus on the focusable target. •
    FocusOrder
    has now been merged into
    FocusProperties
    and
    focusProperties()
    now has all the capabilities of
    focusOrder()
    .
    FocusOrder
    and
    focusOrder()
    have been deprecated.
    focusOrder()
    that accepts a
    focusRequester
    should be replaced with a
    focusRequester()
    modifier in combination with
    focusProperties()
    . This allows the modifiers to have a stronger separation of concerns. •
    WindowInsets.asPaddingValues(Density)
    was added to allow developers to do the conversion without needing to be in composition. • Updated parsing of vector drawables to support auto mirroring to flip the content of a
    VectorPainter
    if the current layout direction is RTL. • Scroll modifiers (
    Modifier.verticalScroll()
    ,
    Modifier.horizontalScroll()
    , and
    Modifier.scrollable()
    ) will now scroll to keep the focused composable visible if the scroll area is resized and the focused composable was previously visible. • Upgrading both
    RecyclerView
    and
    Compose
    will now result in much better scrolling performance for RecyclerViews with Compose views as children. • Reference devices added to the Devices list for @Preview (I071c9) • compose-ui: Add
    ambientShadowColor
    and
    spotShadowColor
    properties to
    GraphicsLayerScope
    (I1ba1a, b/160665122) • Plural resources are now supported via the
    pluralStringResource
    functions. (Ib2f23, b/191375123) • Material3 - Added support for Material 3 text fields. (I795cc, b/199377790)
    :thank-you: 3
    ❤️ 15
    z
    d
    +3
    • 6
    • 9
  • t

    Thomas Dougherty

    03/23/2022, 9:21 PM
    ConstraintLayout(
        constraintSet = constraints,
        modifier = Modifier
            .fillMaxWidth()
            .height(90.dp)
            .clearAndSetSemantics {
                set(SemanticsProperties.ContentDescription, listOf(contentDescriptionText))
            }
            .clickable(onClick = onClick)
            .border(
                width = 6.dp,
                color = Color.Green,
                shape = RoundedCornerShape(topStart = 6.dp, topEnd = 6.dp, bottomEnd = 6.dp, bottomStart = 6.dp)
            )
    ) {
    • 1
    • 1
  • t

    Tim Malseed

    03/24/2022, 2:16 AM
    Is there anyone @Google who could help me find some Compose merch? I’m in Australia.. Just looking for something to use as a gift to reward some of the junior devs on my team
    b
    • 2
    • 5
  • s

    SrSouza

    03/24/2022, 2:34 AM
    Hi folks, I'm trying to create a delegate function that is a
    @Composable
    no problem problem building it. but I'm having runtime exception:
    java.lang.NoSuchMethodError: No virtual method getValue-0d7_KjU(Ljava/lang/Object;Lkotlin/reflect/KProperty;)J
    Does
    @Composable
    support delegate property? Example:
    @Composable
    public operator fun getValue(thisRef: Any?, property: KProperty<*>): Color {
        return animateColorAsState(targetValue = state).value
    }
    r
    z
    • 3
    • 4
  • c

    Colton Idle

    03/24/2022, 5:00 AM
    I updated to latest compose alpha and now I have this compile error regarding a
    Card
    My code
    Card(
        modifier = modifier,
        backgroundColor = color,
        onClick = onClick ?: {},
        indication = if (onClick == null) null else LocalIndication.current,
    ) { content() }
    if I use the alt+enter helper it removes the
    indication =...
    . How can I set an indication on the card now though?
    l
    z
    • 3
    • 8
  • a

    Android75

    03/24/2022, 7:11 AM
    I developed a QRCode scanner, it’s a scanner that add in a container in my old xml layout.. how can i used it in compose ? So how ca i add a Fragment inside a compose layout ?
    r
    j
    • 3
    • 5
  • u

    Utkarsh Tiwari

    03/24/2022, 7:15 AM
    Let’s say we have two focusable TextFields items stack in a column.
    Column {
      TextField() // Let's call it A
      TextField() // Let's call it B
    }
    If I use
    FocusDirection.Down
    when
    A
    is focused, the focus moves down to the
    B
    item below it which is an expected behavior. However, when I use
    FocusDirection.Next
    , nothing happens. The documentation of
    FocusDirection.Next
    says: Direction used in
    FocusManager.moveFocus
    to indicate that you are searching for the next focusable item.
    and I believe that the next focusable item in the above column when
    A
    is in focus should be the
    B
    but it doesn’t seem to work. Am I missing something? 😕
    c
    • 2
    • 1
  • k

    K Merle

    03/24/2022, 7:21 AM
    Are we able to dynamically hide Accompanist pager Tab?
    c
    • 2
    • 2
  • g

    galex

    03/24/2022, 10:23 AM
    Hello, how can I call
    onGloballyPositioned
    inside
    Modifier.composed
    ? That inside modifier doesn’t seem to be called!
    fun Modifier.tooltip(
        scope: CoroutineScope,
        tooltipHostState: TooltipHostState,
        text: String
    ) = composed {
        var layoutCoordinates by remember { mutableStateOf<LayoutCoordinates?>(null) }
        onGloballyPositioned {
            layoutCoordinates = it
            logger().d("tooltip", "onGloballyPositioned = $layoutCoordinates")
        }
    
        LaunchedEffect(layoutCoordinates) {
            logger().d("tooltip", "LaunchedEffect = $layoutCoordinates")
            scope.launch {
                tooltipHostState.showTooltip(text)
            }
        }
        return@composed this
    }
    What I am trying to do is to launch only once (LaunchedEffect) when
    onGloballyPositioned
    is called 🤔
    f
    e
    z
    • 4
    • 24
  • t

    Tomas Gordian

    03/24/2022, 12:00 PM
    Hello, why is recomposition happening in this example even when no parameters has changed and how can I avoid it?
    t
    z
    • 3
    • 10
  • f

    Filip Wiesner

    03/24/2022, 12:01 PM
    Hey, how can I have a pager where each item is also zoomable? Right now I have my
    zoomable
    modifier which contains a
    pointerInput
    with
    detectTransformGestures
    . It works all fine but now I have to use this
    modifier
    on items inside
    HorizontalPager
    and because (I presume) the
    pointerInput
    consumes all the events, I cannot move the pager. What I've tried is to dispatch the unused offset (pan with one finger) as a scroll to the pager but I don't know how to handle the fling after the scroll. Is there some way to handle my own fling? Or is there some more simple way to achieve this that I am missing?
    a
    • 2
    • 4
  • m

    Mantas Varnagiris

    03/24/2022, 1:02 PM
    Hi, I'm trying to understand something about Accompanist Navigation Animation. It seems that when you pop, screen that was behind in a back stack is drawn on top of the current screen that is now popping. With this we cannot do any parallax or similar animations that involves screens being drawn on top of each other. Is there away to force screen that is being popped to be drawn on top?
    i
    • 2
    • 1
  • l

    lhwdev

    03/24/2022, 1:22 PM
    How can I set proper status bar colors for Dialog? I'm creating custom full screen dialog (but it differs; it can extend below system ui). I've managed to do most things except one thing, I cannot properly use system ui controller for Dialog Window. I'm using accompanist-systemuicontroller and it seems to pull window only from
    Activity
    . (there is DialogWindowProvider for this purpose?)
    • 1
    • 3
  • s

    Shaheer Muzammil

    03/24/2022, 1:26 PM
    Hey Guys, I have recently started using Compose and I was using previews to show different states of my views. Now Most of my classes in the application are abstractions so I was able to generate mocks for them and use them accordingly to show different states. but in case some of the final classes that I am using have their constructors as internal. as they should not be initialized from outside of the module. How do I use them? and is this the right approach to make these extensive previews? And should I use mocking libraries like Mokito or Mockk to get this done?
    z
    m
    • 3
    • 4
  • s

    Stylianos Gakis

    03/24/2022, 1:44 PM
    I have a question regarding using
    Layout
    , how it’s used in the implementation of Column|Row measure policy and in a codelab. More in thread 🧵
    a
    z
    • 3
    • 16
  • j

    julioromano

    03/24/2022, 2:20 PM
    Is there an “easy” way to set all of a composable’s inner composables as
    disabled
    ? Maybe something with CompositionLocals? (what I’m trying to achieve is to have an entire screen to be disabled under certain conditions)
    c
    c
    +2
    • 5
    • 10
  • n

    natario1

    03/24/2022, 4:25 PM
    Hi, is anyone seeing broken layouts starting from
    1.2.0-alpha04
    ? We have a couple of components that look completely messed up in 04 (but worked well before). I’m going through the changelog but I can’t find any hint
    • 1
    • 1
  • t

    Tobias Gronbach

    03/24/2022, 4:26 PM
    How do I put a LazyVerticalGrid in a scrollable Column. I get following exception : "java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed. One of the common reasons is nesting layouts like LazyColumn and Column(Modifier.verticalScroll())." What is the recommended approach? I guess this is not an uncommon usecase?
    t
    • 2
    • 5
Powered by Linen
Title
t

Tobias Gronbach

03/24/2022, 4:26 PM
How do I put a LazyVerticalGrid in a scrollable Column. I get following exception : "java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed. One of the common reasons is nesting layouts like LazyColumn and Column(Modifier.verticalScroll())." What is the recommended approach? I guess this is not an uncommon usecase?
t

Thomas Dougherty

03/24/2022, 6:17 PM
What’s the end result you’re trying to achieve?
t

Tobias Gronbach

03/24/2022, 6:22 PM
Hi Thomas, thanks for your question! I have a Filter-Dialog. It contains several lists of filters. For Each List I use a LazyVerticalGrid. The filter-lists require more space than is available on screen so I wanted to place them inside a Column and make it scrollable.
t

Thomas Dougherty

03/24/2022, 6:25 PM
I believe you can achieve that same effect within a LazyColumn itself. Something like:
LazyColumn {
    // Add a single item
    item {
        Text(text = "Header")
    }

    // Add first filters list
    items(firstFiltersList) { filter ->
        Text(text = "Filter: $filter")
    }

    // Add another single item
    item {
        Text(text = "Another Header")
    }

    // Add second filters list
    items(secondFiltersList) { filter ->
        Text(text = "Filter: $filter")
    }
}
Your filter lists would each go in their own items block and the content displayed can be different. I am by no means an expert on Lists in compose yet, but I’m pretty sure there’s no way currently to add the LazyVerticalGrid into a scrollable column.
t

Tobias Gronbach

03/24/2022, 6:29 PM
Yeah maybe I'll go with that approach. I had those Grid-Component already available in a seperate Composable that was quite nicely designed with all the logic and I hoped to be able to just reuse it. But thanks a lot for your idea! I guess I'll go with that approach! 👌
:60fps_parrot: 1
View count: 19