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

    nuhkoca

    04/26/2022, 10:04 PM
    Hello, I am trying to make a custom sticky header as I can’t utilize `LazyColumn`’s because status bar is transparent and there is no `TopBar`(only mimic) in my case so I can’t get the desired
    offset
    and
    index
    at the right time in no way. Can you tell me how can I show my sticky header once the respective item almost goes out of view? Screen recording in the thread
    m
    8 replies · 2 participants
  • a

    andrew

    04/26/2022, 11:44 PM
    Quick Q, is this possible on Android? https://www.pushing-pixels.org/2021/09/22/skia-shaders-in-compose-desktop.html
    ➕ 1
    e
    o
    5 replies · 3 participants
  • t

    Tash

    04/27/2022, 12:52 AM
    When updating
    androidx.compose
    artifacts, do we also need to update
    androidx.activity:activity-compose
    ? (i.e. looking to update compose to
    1.2.0-alpha08
    )
    c
    i
    10 replies · 3 participants
  • c

    Colton Idle

    04/27/2022, 1:00 AM
    In my composable screen I'm doing this.
    val options: List<String> = (1..21).map { it.toString() }
    DropDownPicker(
        options,
    should I wrap the
    (1..21).map { it.toString() }
    in a remember? I'm tempted to file a lint request so that android studio just flags all of these creations as most likely should be wrapped in a remember block.
    c
    c
    +2
    11 replies · 5 participants
  • s

    ste

    04/27/2022, 10:58 AM
    I'm facing a super weird bug (I guess) which triggers an endless recomposition, it took me a while to narrow it down to a minimal reproducible example (15 LOC snippet in first comment)... Edit: https://issuetracker.google.com/issues/230530875
    👀 2
    4 replies · 1 participant
  • e

    Eric Martori

    04/27/2022, 11:27 AM
    Is there a way to show a Compose popup or dialog from an Android custom view? We have lots of Android custom views that we don't have the time to migrate fully to compose, but we are adding new developments in compose gradually. Adding
    ComposeView
    in the XML works for most cases, but now we have to show a pop window and an alert on user interaction. We have tried creating the
    PopupWindow
    and
    AlertDialog
    programmatically and setting the content view as a
    ComposeView
    with the desired content but we get errors like:
    java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from android.widget.PopupWindow$PopupDecorView
    So we are thinking that maybe there is a way to launch the alert and popup directly from compose, but don't know how to launch it from inside a custom view without replacing the already working content.
    m
    a
    18 replies · 3 participants
  • c

    Chachako

    04/27/2022, 1:09 PM
    Is there any way to create a family of fonts with delayed loading? I have a library that has multiple font weights in assets, the library by default just uses regular and bold fonts, the remaining multiple font weights should be used by the user. After browsing through the source code I found that it seems that only the
    fun Font(resId: Int, ...)
    is lazily loaded, the fonts created via
    fun Font(assetManager: AssetManager, ...)
    and
    fun Font(file: File, ...)
    are loaded immediately, so what should I do? Is there anything that might be called LazyAssetsFont?
    a
    2 replies · 2 participants
  • j

    Jan

    04/27/2022, 2:17 PM
    Hey I think thats not the right approach: I want to have a map where the key is the "shop" and the value is a list of products. I currently use this for the map and this function for adding a value:
    private val products: SnapshotStateMap<String, List<ShoppingItem>> = mutableStateMapOf()
    
    fun add(shop: String, product: ShoppingItem) {
        val list = products.getOrDefault(shop, mutableListOf()).toMutableList()
        list.add(product)
        products[shop] = list
    }
    
    fun replace(shop: String, product: ShoppingItem) {
        val list = products.getOrDefault(shop, mutableListOf()).toMutableList()
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            list.replaceAll { if (it.id == product.id) product else it }
        }
        products[shop] = list
    }
    I mean adding works but the replace method doesn't wanna work and I don't think thats the right way
    h
    10 replies · 2 participants
  • c

    Chris Fillmore

    04/27/2022, 4:02 PM
    I am trying to implement a timeout on app backgrounding, because I have several open socket connections with stateful services. I am using Compose navigation with a VM scoped to a “Main” screen.
    5 replies · 1 participant
  • v

    Vahalaru

    04/27/2022, 4:48 PM
    Can someone Explain to me if you would ever want to make a hybrid come a hybrid compose an XML android app. Would there be any benefits to designing an app that uses both
    a
    m
    9 replies · 3 participants
  • j

    Jan

    04/27/2022, 5:52 PM
    I have this on the start of my application:
    LaunchedEffect(Unit) {
                while(true) {
                        delay(7000)
                        try {
                            productMap.fill(ShoppingRepository.getProducts())
                        } catch(e: Exception) {
                            productMap.fill(cache)
                            e.printStackTrace()
                        }
                    }
            }
    Does this get stopped when the process is not in the foreground or something?
    o
    o
    3 replies · 3 participants
  • a

    agrosner

    04/27/2022, 7:08 PM
    in the roadmap for “Recomposition Tooling” is there any insight into what tooling will be provided? My team and I are talking about how we can roll out compose to a larger group of devs accross our company. Right now seems to not be so much guardrails around recomposition and lint checks warning / (potentially errorring) when functions are not skippable. So we’re debating whether to invest time in some tools to provide the necessary guard rails., or there is plans in the next year to release something
    c
    5 replies · 2 participants
  • s

    Saiedmomen

    04/27/2022, 7:35 PM
    Is there a reason for the vanilla
    SideEffect
    not having key args? In the example in the official docs, you can see that there easily can be extra calls to the analytics. The
    LaunchedEffect
    is great but the suspend block is sometimes not needed and wasteful.
    @Composable
    fun rememberAnalytics(user: User): FirebaseAnalytics {
        val analytics: FirebaseAnalytics = remember {
            /* ... */
        }
    
        // On every successful composition, update FirebaseAnalytics with
        // the userType from the current User, ensuring that future analytics
        // events have this metadata attached
        SideEffect {
            analytics.setUserProperty("userType", user.userType)
        }
        return analytics
    }
    t
    r
    18 replies · 3 participants
  • a

    Andrew Hughes

    04/27/2022, 10:04 PM
    The M3 (and I think M2 as well, but I haven't checked)
    TextField
    and
    OutlinedTextField
    both appear to animate changes (such as color) when transitioning to and from the
    isError
    state. When including an error message below a
    TextField
    , there doesn't appear to be a way to synchronize the appearance of the error message with the internal animations of the
    TextField
    . For example, take the following sample from the official M3 compose samples:
    @Sampled
    @Composable
    fun TextFieldWithErrorState() {
        val errorMessage = "Email format is invalid"
        var text by rememberSaveable { mutableStateOf("") }
        var isError by rememberSaveable { mutableStateOf(false) }
    
        fun validate(text: String) {
            isError = !text.contains('@')
        }
    
        Column {
            TextField(
                value = text,
                onValueChange = {
                    text = it
                    isError = false
                },
                singleLine = true,
                label = { Text(if (isError) "Email*" else "Email") },
                isError = isError,
                keyboardActions = KeyboardActions { validate(text) },
                modifier = Modifier.semantics {
                    // Provide localized description of the error
                    if (isError) error(errorMessage)
                }
            )
            // Supporting text for error message.
            Text(
                text = errorMessage,
                color = MaterialTheme.colorScheme.error,
                style = MaterialTheme.typography.bodySmall,
                modifier = Modifier.padding(start = 16.dp, top = 4.dp).alpha(if (isError) 1f else 0f)
            )
        }
    }
    I see that internally the animations are using a 150ms tween animation, but there's no way to reference this directly since it's marked as
    internal
    . Is there a recommended way to synchronize these components?
    c
    2 replies · 2 participants
  • n

    natario1

    04/27/2022, 10:48 PM
    Does anyone know why Rect.contains(Offset) would not consider the end and bottom sides? I see that it’s documented, but still don’t get it 😄
    r
    1 reply · 2 participants
  • d

    David Nadejdin

    04/28/2022, 7:50 AM
    Hello everyone!! Why I see this https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary#Chip(kotlin.Function0,androi[…].Function0,kotlin.Function1), but it's missing. Maybe I need to change the library source or anything else? Maybe has material 3 roadmap? More than a year has passed but all components have not been implemented
    f
    7 replies · 2 participants
  • s

    Satyam G

    04/28/2022, 8:51 AM
    How to display the ModalBottomSheetLayout in such a way it will hide the BottomBar. https://stackoverflow.com/questions/72038434/modalbottomsheet-is-showing-above-bottombar-in-jetpack-compose?noredirect=1#comment127289219_72038434
    f
    c
    +1
    10 replies · 4 participants
  • i

    ildar.i [Android]

    04/28/2022, 10:46 AM
    I noticed that the ripple effect transfers to the next item in Column if you have it on a delete button. How can I mitigate it?
    screen-20220428-164355.mp4
    f
    5 replies · 2 participants
  • p

    Philipp Kleber

    04/28/2022, 1:08 PM
    Are `LaunchedEffect`(s) and `DisposableEffect`(s) guaranteed to be executed in order of composition? To illustrate this, let's say I quickly switch between two routes using a
    NavController
    and both of these routes have a
    DisposableEffect
    . Is the last effect of the route I stop at guaranteed to have been executed after the effect of the other route (the one which I did not stop at)?
    a
    3 replies · 2 participants
  • f

    Francescos

    04/28/2022, 1:51 PM
    I use Navigation Compose and my usecase is to track a screen view event for each screen. Nevertheless, when I navigate from screen A to screen B and then back to screen A (which is already in the back stack), I’d like to track screen view event of screen A only once. I tried with both LaunchedEffect (Unit) and DisposableEffect (https://developer.android.com/jetpack/compose/side-effects#disposableeffect) but both of them are going to be invoked again when navigating to a screen already in the back stack. Am I missing something?
    m
    c
    +1
    7 replies · 4 participants
  • m

    myanmarking

    04/28/2022, 2:42 PM
    feature suggestion: Kotlin Compose Compiler Plugin, similar to kotlin bytecode - that would show skippable/restartable/stable information for the current file ❤️
    👍 1
    f
    z
    3 replies · 3 participants
  • d

    Daniel Okanin

    04/28/2022, 4:14 PM
    Hello everyone! I have an issue with my LazyColumn. Im trying to display a list of notifications items but the list is so slow and laggy. I wrap my modal with stable annotation (see the NotificationViewModelItem below), but still have a state field inside. I figure out that when I set my Lazy Column under a Scaffold the list isn’t laggy anymore. Is it related? maybe is related to the SubcomposeLayout inner view that exists there? Thanks
    :plus1: 1
    f
    g
    +3
    14 replies · 6 participants
  • n

    nuhkoca

    04/28/2022, 5:11 PM
    Hello! How can I apply
    depth
    animation to my component, similar to
    DepthPageTransformer
    in
    ViewPager
    👀 1
    c
    7 replies · 2 participants
  • i

    Ink

    04/28/2022, 10:04 PM
    Hi! I'm having troubles with displaying photos in
    HirozontalPager()
    It always displays the same photo.
    product.photos
    is a List<String> with different links to photos.
    m
    3 replies · 2 participants
  • s

    Slackbot

    04/28/2022, 11:45 PM
    This message was deleted.
    m
    1 reply · 2 participants
  • j

    Jérôme Gully

    04/29/2022, 6:55 AM
    Hello here 👋. I’m investigating how to get a view tree from a :compose: screen, in an efficient manner. I have tried to use Radiography from Square, but it uses
    composer.compositionData.asTree()
    , which is too slow for my needs (500ms for a simple view). There is also Semantics, used by Talkback, it seems lighter, but is not used for every composable/Group, especially for custom views. I talked a bit about my problem with a person from Google at Android Makers this monday (sorry I don’t remember your name, maybe @Clara Bayarri) and I will be happy to continue the discussion here. Is there an efficient solution that can be found by using SlotTables/Group directly? I will buy the book Jetpack Compose Internals to go further but any help to move faster will be welcome, thank you 🤓.
    z
    2 replies · 2 participants
  • m

    Mohan manu

    04/29/2022, 9:12 AM
    How can we restrict android system keyboard not to show when clicked on compose text field while retaining the focus? Which we usually achieve with appcompatedittext by setting showSoftInputOnFocus to false.
    t
    1 reply · 2 participants
  • a

    Arjan van Wieringen

    04/29/2022, 9:52 AM
    Where can I find some information about the Composable annotation and the corresponding compiler plugin? I am interested in using it for an own tree structure. I found two blog articles (https://arunkumar.dev/jetpack-compose-for-non-ui-tree-construction-and-code-generation/ and http://intelligiblebabble.com/compose-from-first-principles/). But I was hoping to find some more low-level information. Is there any available?
    a
    c
    +1
    20 replies · 4 participants
  • s

    ste

    04/29/2022, 11:10 AM
    What's the suggested approach to handle re-launchable effects in raw compose (no viewmodels)? E.g. I'd like to create a retry button which repeats an operation (when a network request fails or whatsoever). I came to this hacky solution 🧵 (which seems to work well!), are there problems I'm unaware of?
    z
    5 replies · 2 participants
  • i

    iamthevoid

    04/29/2022, 12:08 PM
    What is the proper way to place buttons in column in AlertDialog when it length greater than the dialog width?
    t
    9 replies · 2 participants
Powered by Linen
Title
i

iamthevoid

04/29/2022, 12:08 PM
What is the proper way to place buttons in column in AlertDialog when it length greater than the dialog width?
I try to solve it with
onTextLayout
here i check if text wrap and call callback
Here - if callback triggered i replace row with column
t

Tolriq

04/29/2022, 12:09 PM
Depends on the needs but sometimes I use https://google.github.io/accompanist/flowlayout/
i

iamthevoid

04/29/2022, 12:10 PM
But result looks next
t

Tolriq

04/29/2022, 12:12 PM
Alert dialogs with default options are bugged and are not resized when content change there's an open issue about that.
😯 1
i

iamthevoid

04/29/2022, 12:17 PM
And how to Flow Layouts can help me with resizing buggy alert dialog?
t

Tolriq

04/29/2022, 12:55 PM
Because it's done at first measure pass.
View count: 5