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

    zt

    06/18/2022, 12:53 AM
    When launching my app, the navbar and status bar flicker black for a very small amount of time, less than half a second before it gets set to the proper color I'm using the system UI controller accompanist library to be able to set it but the flicker is something I want to fix somehow
    j
    t
    • 3
    • 4
  • z

    zt

    06/18/2022, 3:54 AM
    I'm using compose material 3 1.0.0-alpha13 and found that the swipeable modifier is marked as internal. Is there something that changed or was this some mistake?
    c
    a
    +2
    • 5
    • 6
  • l

    Lokik Soni

    06/18/2022, 5:28 PM
    Hi all I am getting color from state different in two places in same screen. State class:
    data class AddEditNoteState(
       val color: Int = Note.noteColors.random().toArgb(),
    )
    In ViewModel:
    private val _addEditNoteSate = MutableStateFlow(AddEditNoteState())
    val addEditNoteState = _addEditNoteSate
       .asStateFlow()
       .stateIn(viewModelScope, WhileViewSubscribed, AddEditNoteState())
    In Compose:
    val addEditNoteState by rememberFlowWithLifecycle(viewModel.addEditNoteState).collectAsState(AddEditNoteState())
    val noteBackgroundColor = remember {
       Animatable(
          Color(if (noteColor != -1) noteColor else addEditNoteState.color)
       )
    }
    Now when I access addEditNoteState.color and noteBackgroundColor.value Both are different. Not able to find the error. Note (noteColor != -1) is not true means we are using addEditNoteState.color in Animatable*
    z
    • 2
    • 2
  • m

    Marcin Wisniowski

    06/18/2022, 7:10 PM
    How would I achieve a composable with a hole in the middle, like on this image? I mean the dark overlay, which covers the camera preview under it. It covers some area while having a portion in the middle fully see-through.

    https://raw.githubusercontent.com/googlesamples/mlkit/master/android/material-showcase/screenshots/live_barcode.gif▾

    :stackoverflow: 1
    ✅ 1
    :not-kotlin: 1
    s
    • 2
    • 3
  • c

    Chris Fillmore

    06/18/2022, 9:22 PM
    Hey Mods, I submitted my app to the Play Store for review yesterday; it’s built entirely in Compose. When it gets released, can I make a note of it here? Not sure if there’s a rule about these sorts of announcements. Alternately I could put it in #feed, but the actual content of the app may not be that interesting to developers (it’s a live video / commerce app). No problem if that’s not allowed. Thanks
    z
    l
    c
    • 4
    • 3
  • z

    zt

    06/18/2022, 11:30 PM
    How can I make
    detectDragGesturesAfterLongPress
    where I'm able to handle the gesture differently depending if its horizontal or vertical? there's handlers for those directions but neither of them are after a long press
    t
    • 2
    • 4
  • k

    kotlinforandroid

    06/19/2022, 11:27 AM
    I have some problems with
    InlineTextContent
    . I am trying to add readings annotations to existing text. However, if I simply add the exact same text using a placeholder, the text gets added written vertically for some reason. I think the reason is that the placeholder width isn't exactly the same as the width the original text would have needed. But the way I did it I do not see the issue. (thread)
    z
    • 2
    • 4
  • a

    Arjan van Wieringen

    06/19/2022, 2:26 PM
    Just a simple question. Is it a compose anti-pattern to have a complete
    State
    as input of your root composable and have all subcomposables take either directly some subelements of that state or some
    derivedState
    ? I can imagine that the runtime will trigger a recalc on the root component every time the top-level state is changed and this might be suboptimal.
    s
    m
    • 3
    • 3
  • a

    Ali

    06/19/2022, 6:16 PM
    Hello friends! I've coded two apps by Kotlin / Jetpack Compose, MVVM, mostly for my own familiarity with Android Coding (With a long background of Mlultiplatform coding by AS3, but completely unfamiliar with Java and the native environment), both of which are now on Google Play, totally free: https://play.google.com/store/apps/details?id=com.divaryab.hesab https://play.google.com/store/apps/details?id=com.divaryab.todo I'm going to add the Drag & Drop feature to the next version of the ToDo app, above. I have found some resources, however still not sure how to apply that to my code. Does anyone want to participate in this project with me? Either I put it publicly on GitHub to work on it, or we work on it privately, what do you recommend? Again, these apps are completely free and will remain free, my goal is to learn and at the same time produce some apps that are as simple as possible for the user to use.
  • o

    orangy

    06/19/2022, 8:31 PM
    Hello, I’m doing some fancy stuff with
    AnnotatedString
    and
    InlineTextContent
    and what blocks me is the static structure of
    Placeholder
    ’s width & height. What I’d like to have is placeholder’s size to be derived from the text measurements it replaces. For example, like
    this text in Slack
    I’d like to put background (that I can with SpanStyle) and a border (which is missing from SpanStyle) with rounded rectangle (also not in SpanStyle). I could do this easily with
    InlineTextContent
    if only I could measure it relative to text size, e.g. with some margins/paddings, etc. Any ideas? Thanks!
    k
    c
    +2
    • 5
    • 14
  • y

    Yacov Rosenberg

    06/19/2022, 9:30 PM
    Guys, how can achieve this surface with top shadow in compose?
  • y

    Yacov Rosenberg

    06/19/2022, 9:30 PM
    i
    c
    • 3
    • 2
  • c

    Chris Fillmore

    06/20/2022, 3:00 AM
    Is there a
    DropdownMenu
    -like composable that is a row instead of column? I just want a floating tray of icons basically
    c
    k
    • 3
    • 3
  • z

    zt

    06/20/2022, 3:23 AM
    Can I somehow make a boolean thats watched and when its true it gets set to false after a few seconds, with the ability to reset the timer. I'm going for a thing that will autohide the UI after inactivity
    c
    • 2
    • 1
  • j

    Jitendra

    06/20/2022, 3:41 AM
    I need to get context in view model , I am trying to get using localcontext but it is keep giving error @composable invocation can only happen from the context of composable function, what is the best way to get context/activity instance in viewsmodel
    f
    a
    k
    • 4
    • 3
  • f

    fengdai

    06/20/2022, 7:42 AM
    Will
    AndroidView
    recreate view when
    LocalContext.current
    changed?
    f
    t
    • 3
    • 16
  • m

    Mahdi Safarmohammadloo

    06/20/2022, 8:54 AM
    simple question (Probably duplicate 😁) ! i have father and child compose function , i set a mutable state in father compose function , how can i change father state in child compose function ? (when i pass it as a parameter it is only readable)
    f
    k
    • 3
    • 3
  • s

    Satyam G

    06/20/2022, 11:19 AM
    Hello, Does Anyone have idea on how to clear the ViewModel if any composable screen associated with that VM is not visible when other screen is Opened ? The issue is When the ABC screen is open I am doing the API call inside Init block of ViewModel. After switching the screen again when the screen is opened the init block is not called and No updated Api call happens
    a
    a
    k
    • 4
    • 8
  • a

    allan.conda

    06/20/2022, 11:47 AM
    Compose Navigation question: How can we fix the flicker between the
    startDestination
    and the FTUE destination on startup? I’m not sure why the
    startDestination
    is still rendered briefly even if the backstack already has the FTUE destination at the top of the queue before the first render (via onPreDrawListener). We’re trying to keep following the navigation principles about above scenario but the flicker is really ugly. Anyone solved this yet?
  • t

    Tower Guidev2

    06/20/2022, 11:54 AM
    Hi, i am investigating
    androidx.compose.material.BackdropScaffold
    i am attempting to use compose
    Material3
    theming. however my backdrop doesnt react to switching between light and dark mode, where other activities do. is this because
    BackdropScaffold
    is not a
    Material3
    component? How do i get backdrop theme to respect Light & Dark mode ?
  • c

    Cyril Kym

    06/20/2022, 12:24 PM
    Hi everybody, is there any solution with compose to check if a path on the canvas was touched? My paths are drawing the cantons of switzerland, which makes using bounding rectangles not a viable solution. My current implementation checks for the location of the touch and compares it to the location of the text elements, which works quite well, but being able to correctly match touch to path could propably be a better solution.
    m
    e
    • 3
    • 2
  • k

    kotlinforandroid

    06/20/2022, 12:27 PM
    Is it possible to make
    Text
    respect the height constraint of
    InlineTextContent
    ? As of now, if I use inline content that is too tall, it starts to overlap with the text from the line above. Ideally,
    Text
    would somehow increase the line height during rendering to not introduce such overlays.
  • j

    Jan Skrasek

    06/20/2022, 12:50 PM
    So I'm updating to Compose 1.2 and using
    includeFontPadding = false
    and
    LineHeightStyle.Align.Center
    +
    LineHeightStyle.Trim.None
    . I observe an issue in TextField - if it is empty, the cursor gets smaller/decreased. This seems to be issue only with my proprietary font - the default font is ok. Anyway how to debug what's wrong? Some font-metric could be off? But why it is present only with empty value? Issue is similar to this fixed one. cc @Siyamed
    • 1
    • 2
  • z

    ziv kesten

    06/20/2022, 1:13 PM
    Does anyone have a good shadow modifier implementation? I use this:
    fun Modifier.advancedShadow(
        color: Color = Color.Black,
        alpha: Float = 0f,
        cornersRadius: Dp = 0.dp,
        shadowBlurRadius: Dp = 0.dp,
        offsetY: Dp = 0.dp,
        offsetX: Dp = 0.dp
    ) = drawBehind {
    
        val shadowColor = color.copy(alpha = alpha).toArgb()
        val transparentColor = color.copy(alpha = 0f).toArgb()
    
        drawIntoCanvas {
            val paint = Paint()
            val frameworkPaint = paint.asFrameworkPaint()
            frameworkPaint.color = transparentColor
            frameworkPaint.setShadowLayer(
                shadowBlurRadius.toPx(),
                offsetX.toPx(),
                offsetY.toPx(),
                shadowColor
            )
            it.drawRoundRect(
                0f,
                0f,
                this.size.width,
                this.size.height,
                cornersRadius.toPx(),
                cornersRadius.toPx(),
                paint
            )
        }
    }
    But it's not perfect.
    a
    m
    • 3
    • 6
  • b

    Bradleycorn

    06/20/2022, 3:40 PM
    👋 Hi all! I’m tying to setup a transparent status bar, via the Accompanist SystemUIController, with no luck. Hopefully someone can tell me what I’m doing wrong …. My Activity’s
    onCreate
    looks like this:
    WindowCompat.setDecorFitsSystemWindows(window, false)
    
    setContent {
        MyAppTheme {
            val systemUIController = rememberSystemUiController()
            SideEffect {
                systemUIController.setStatusBarColor(
                    color = Color.Transparent,
                    darkIcons = true
                )
            }
       }
    }
    But the status bar is rendered as solid white, as shown in this screenshot (note how the text at the top is cut off as it scrolls under the status bar)
    c
    j
    • 3
    • 2
  • v

    Vaios Tsitsonis

    06/20/2022, 4:36 PM
    Hello! I ve created a list that syncs with a tabrow. Whoever is interested in learning more in the implementation or want to use it, he can find it [here](https://github.com/St4B/smart-tabs)
    👍 3
  • l

    Lokik Soni

    06/20/2022, 4:48 PM
    I am showing Snackbar on NoteScreen but when the Snackbar is showing and I navigate to next screen and again go to back i.e NoteScreen Snackbar shows again . What is the best way to solve this.
    s
    t
    d
    • 4
    • 19
  • b

    Billy Newman

    06/20/2022, 6:51 PM
    Hello all, having trouble wrapping my head around an infinite lazycolumn using the pager v3 library. I would like to scroll up infinitely as new “un-viewed” items are available. This means that on initial load of the view, I would like to start the user at the bottom of the list, not the top.
    d
    i
    • 3
    • 4
  • z

    zt

    06/20/2022, 7:38 PM
    How would I change the orientation of the screen on a button press?
  • l

    Luke

    06/20/2022, 7:50 PM
    What is the default
    lineHeight
    for
    Text
    in Compose? I know the default value is
    TextUnit.Unspecified
    , but I want to have a
    lineHeight
    that is whatever default value, times a value given from our backend.
Powered by Linen
Title
l

Luke

06/20/2022, 7:50 PM
What is the default
lineHeight
for
Text
in Compose? I know the default value is
TextUnit.Unspecified
, but I want to have a
lineHeight
that is whatever default value, times a value given from our backend.
View count: 21