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

    Paul Woitaschek

    02/23/2022, 11:11 PM
    I created a bunch of spaghetti to get a tooltip with a triangle working. I’m basically using onGloballyPositioned, then based on that value modifying another state from within the PopupPositionProvider and use that to draw. https://github.com/PaulWoitaschek/Voice/commit/aef79d775e5202d652deb17636ce74e30f8aa2e5#diff-bc525946a19e216be9fcf2dfac5b38b0964481394c73114c9120812144c2cdc4 Is there a simpler way to accomplish that?
    ➕ 3
    🎉 1
    • 1
    • 1
  • j

    jasu

    02/24/2022, 6:00 AM
    We have a large codebase, so creating composables and previewing taking on avg 1-2mins even on macbook pro intel. So I want to build compasables in an isolated package where I have a dependency of another package(which provides our design system for compose) and installing installs only this testing apk with 1 activity so that my basic composable building time reduce as I’m currently having bad time. Can anyone help me how can I achieve this?
    e
    a
    +2
    • 5
    • 11
  • y

    Yoshio Schermer

    02/24/2022, 8:08 AM
    Is there something like this, so I don’t have to wrap every Preview Composable with my Theme?
    @Preview(theme = MyTheme)
    @Composable
    fun PreviewComposable(){
        Text(text = "foo")
    }
    a
    z
    +3
    • 6
    • 19
  • l

    Lance Gao

    02/24/2022, 8:42 AM
    Hi all, I use font poppins in Compose
    Text()
    but the content alignment looks not good, any solutions? Thanks. Code:
    Text(
        text = "NEXT",
        fontSize = 150.sp,
        fontWeight = FontWeight.Bold
    )
    Preview:
    f
    • 2
    • 2
  • z

    ziv kesten

    02/24/2022, 10:00 AM
    Has anyone figured out a way to show scroll bars in columns?
    👀 1
    :party-parrot: 1
    a
    z
    c
    • 4
    • 11
  • c

    Cheryl Bennett

    02/24/2022, 10:28 AM
    Hi everyone. I'm really struggling with getting the values of stringResource to update after a locale switch. They update if I close the app and then re-open but if I change locale mid app session, it doesn't. The composable screen is built within a fragment as we’re trying to integrate it into an existing app. The screen in question has multiple stringResources so it's not practical to use mutable state for each one. Has anyone experienced something similar and found a working solution? I think I need to trigger a recomposition but I'm not sure how to do that. Apologies if this is the wrong place to ask. This is my first time raising a question here. Thanks in advance.
    g
    • 2
    • 3
  • z

    Zoltan Demant

    02/24/2022, 10:30 AM
    Just a cautionary tale, when using
    AnimatedContent
    (and its variants); if the
    targetState
    changes at all, even if it doesnt result in a new animation running, there will be additional recompositions as a result (I was seeing 2-9, instead of 1). I learned this the hard way, Id normally specify what I wanted to render as the
    targetState
    and use
    transition.contentKey
    to key it correctly; stripping out the stuff not directly related to the animation made an immense difference. Ill share some more details in the thread for anyone interested, I dont think this is a bug, but rather me misunderstanding how it works - hopefully it can save you from doing the same mistake as I did!
    i
    c
    • 3
    • 4
  • j

    Johan Reitan

    02/24/2022, 10:49 AM
    Has anyone been able to display
    LazyColumn
    sections as `Card`s like described in this thread? I am trying to implement the following design, where each section could contain 100s of items. This is why I’m hesitant to chuck the whole section inside a
    Column
    , and loose the benefits of
    LazyColumn
    . A workaround that I’ve used successfully in
    RecyclerView
    earlier, is to use a
    Card
    in each item and modify its corners so that it looks like a whole card when put together. In Compose, however, this workaround produces shadows between every item, as described in the thread I mentioned. That particular issue is marked as Won’t Fix (Infeasible).
    z
    c
    • 3
    • 5
  • a

    Aleksandar Aleksiev

    02/24/2022, 12:29 PM
    Hi all, is there a way to get the bounding rectangle of selected text in TextField? Text composable has
    onTextLayout
    but not the
    TextField
    z
    • 2
    • 1
  • v

    Vaios Tsitsonis

    02/24/2022, 2:57 PM
    Hello! I am trying to load a layer-list drawable with this code:
    Image(
        painter = painterResource(id = someId),
        contentDescription = null
    )
    but i get this error:
    Only VectorDrawables and rasterized asset types are supported ex. PNG, JPG
    . I can load vector drawables so I suppose that I need to load layer-list differently... How is this possible?
    m
    c
    n
    • 4
    • 7
  • n

    Nat Strangerweather

    02/24/2022, 4:37 PM
    How can I reload (recompose) my game board on the click of a button? 🧵
    c
    • 2
    • 6
  • c

    Chris Fillmore

    02/24/2022, 4:44 PM
    Any tips on troubleshooting
    pointerInput
    dead zones in your UI? I have some draggable elements that drag fine in some parts of the screen, but stop responding to drag events if I drop them in a particular area of the screen. I assume for now that I have some other UI (perhaps hidden) which may be capturing the touch input. But just reviewing the code, I haven’t spotted the source of the problem.
    a
    • 2
    • 4
  • c

    Chris Fillmore

    02/24/2022, 5:21 PM
    I’m using
    pointerInput
    to detect dragging, and the area that receives the input doesn’t drag along with the element. That is, say I start with something in the center of the screen, and I drag it to the top-left. I can no longer drag that element by putting my finger on it in the top left and dragging. However, if I put my finger in the center of the screen and drag from there, I can drag the item.
    • 1
    • 1
  • t

    Tolriq

    02/24/2022, 5:57 PM
    So asking again for some advice on how to debug / repro a Compose issue with keyboard. Randomly without any text composable anywhere when returning to the app from home the keyboard will open. When it happens closing the keyboard, going home, returning to the app will bring back the keyboard again. I have no idea what I can observe / could generate that to try to build a repro 😞
    i
    c
    z
    • 4
    • 36
  • m

    Marin Tolić

    02/24/2022, 7:05 PM
    Hey you awesome folks,. Do you know if there is a way to pass a click through to the Composable's parent. Now I have to specifically add that I'm not talking about event propagation via lambdas. That's easy to achieve but since this is an SDK question essentially I'm trying to avoid it due to complicating the composable in question and introducing a breaking change. I have an annotated string and only the links should be clickable, the rest of the text should not capture clicks but gracefully let the parent composable handle them. Now this is tricky because this is done via
    Modifier.pointerInput()
    which still has to make the whole Composable area clickable and then decide when it should treat it as a clickable link on a per section basis. I'm wondering if there is any way in compose to say yup point
    x=1, y=1
    should be treated as a click on the
    Text
    Composable but point
    x=2, y=2
    should be treated as a click on its parent. Unsure if this is doable, but if it is it will allow me to implement a really clean and easy to use solution. 😄 Thank you!
    c
    b
    • 3
    • 4
  • a

    aoriani

    02/25/2022, 3:13 AM
    I am implementing a barcode scanner in Compose. Once it scans a barcode, it needs to do a network request to find the respective item. If an item is found I dismiss the scanner. If it is not found or some error happens, a dialog is shown. In order to accomplish that I think that I will need to do something along these lines:
    data class DialogState(val isShown: Boolean = false, val message: String = "")
    
    @Composable
    fun Screen(navController: NavController, viewModel: MyViewModel) {
        val dialogState by rememberUpdateState(DialogState)
        val scope = rememberCoroutineScope()
        Button(onClick = { scope.launch { 
            when (val result = viewModel.doRequest()) {
               is Success -> navController.popBackStack()
               is NotFound -> dialogState = DialogState(true, "Not Found")
               else -> dialogState = DialogState(true, "error")
       }})
       if (dialogState.isShown) {
           AlertDialog(.......) 
       } 
              
    }
    Would this be correct ?
    e
    z
    • 3
    • 5
  • u

    Utkarsh Tiwari

    02/25/2022, 5:28 AM
    Hi, any suggestions on how we can achieve this loopable pager/tab layout with
    ScrollableTabRow
    and
    HorizontalPager
    ?
    w
    • 2
    • 5
  • t

    Tiago Nunes

    02/25/2022, 10:05 AM
    Hi everyone, Can I apply @PreviewParameter to an argument that's a List? e.g.:
    @Preview
    @Composable
    fun MenuPreview(
        @PreviewParameter(MenuItemPreviewParameterProvider::class) menuItems: List<MenuItem>
    ) {
        MdcTheme {
            Menu(menuItems)
        }
    }
    
    class MenuItemPreviewParameterProvider : PreviewParameterProvider<MenuItem> {
        override val values = sequenceOf(
            MenuItem("Beer & Other"),
            MenuItem("More"),
            MenuItem("Shop All Products"),
        )
    }
    I would expect menuItems argument to be a list with the 3 sample values
    p
    • 2
    • 1
  • z

    Zoltan Demant

    02/25/2022, 10:09 AM
    In some cases my apps state is not saved/restored after the app has been in the background for a while (<5 min). Ive reported it as a bug, but Im having a hard time understanding how it could be a bug - so many apps would break, and I probably wouldnt be the first to run into it. So, am I doing something wrong? Code & more details in thread 🧵
    a
    • 2
    • 7
  • z

    ziv kesten

    02/25/2022, 12:17 PM
    Can I have a lazyColumn updating with more items, increase its container size? I can listen to the items and animate the container height but I was wondering if there is any modifier like WRAP_CONTENT to help with that.
    a
    m
    • 3
    • 12
  • n

    Nat Strangerweather

    02/25/2022, 4:12 PM
    I have these two variables at the top of my Composable:
    var enabled by remember { mutableStateOf(true) }
    and
    var visible by remember { mutableStateOf(true) }
    . When I reload the Composable with new data, these variables do not return to their original
    true
    value. Why is that? And how can I make sure they are updated too?
    k
    a
    • 3
    • 23
  • f

    Francois Morvillier

    02/25/2022, 5:07 PM
    Hi! I find myself needing to specify background and foreground colors for every component in order to have the Dark Theme properly applied. This feels like too much work. Is there a better way?
    Card(backgroundColor = MaterialTheme.colorScheme.surface) {
        Text(text, color = MaterialTheme.colorScheme.onSurface)
    }
    Is there a good guide to best practices on the topic?
    c
    k
    c
    • 4
    • 20
  • a

    Ankur Gupta

    02/25/2022, 5:27 PM
    Hey! Is it possible to print logs while using Previews especially Interactive Previews?
    c
    m
    • 3
    • 3
  • s

    Shreyas Patil

    02/25/2022, 7:06 PM
    Just like we can handle Gboard image/gif selection in EditText with the help of InputConnection, how can same achieved with Compose's TextField/BasicTextField? Ref: https://developer.android.com/guide/topics/text/image-keyboard
    🔥 2
    👀 1
    a
    s
    • 3
    • 4
  • t

    Tobias Gronbach

    02/26/2022, 1:19 PM
    Hi I want to create a speechbubble. I created an image and a text inside a Box. I want the speechbubble-image (vector image) to adapt it's size to the text-size. To do that I would have to measure the size of the text and apply it to the image. What would be the correct approach to that? Any hints?
    b
    s
    • 3
    • 3
  • b

    brabo-hi

    02/26/2022, 7:56 PM
    Hi all, how could we display emoji in compose text
    p
    • 2
    • 1
  • s

    Scott Kruse

    02/26/2022, 9:37 PM
    Is there a multiplatform compose version compatible w/ Kotlin 1.6.20-M1?
    o
    • 2
    • 1
  • m

    Marcin Wisniowski

    02/26/2022, 10:20 PM
    The
    @Preview(showSystemUi = true)
    option shows the status bar overlaid over the content, which is not what's usually wanted. Am I missing something?
    ➕ 1
    c
    p
    • 3
    • 13
  • m

    Mehdi Haghgoo

    02/27/2022, 3:59 AM
    Is simply changing a local state variable in a composable considered a side effect?
    p
    h
    • 3
    • 6
  • s

    skwalking

    02/27/2022, 9:50 AM
    What's the preferred way of navigating between the screens in compose ? (which will not change in near future)
    c
    m
    +4
    • 7
    • 7
Powered by Linen
Title
s

skwalking

02/27/2022, 9:50 AM
What's the preferred way of navigating between the screens in compose ? (which will not change in near future)
c

Colton Idle

02/27/2022, 10:22 AM
https://developer.android.com/jetpack/compose/navigation
m

Michael Paus

02/27/2022, 1:49 PM
@Colton Idle Only if you want to be bound to Android for ever. If you have an interest in platform independence you should look elsewhere.
a

Adam Powell

02/27/2022, 2:52 PM
I'd venture a guess that any actively developed offering in this space today is likely to see major conceptual and API changes in the next ~18 months to two years. There's a lot of active thinking around navigation right now through the community and I think it's going to evolve rapidly. Features like movable content and animation enhancements add new requirements and remove old limitations, and growing understanding around general state management does the same. Not to mention the UX zeitgeist.
👍 1
Most projects are best off picking a navigation solution that solves your problems *today*; don't spend time trying to pick a 5-10 year winner here yet
👍 3
s

Scott Kruse

02/27/2022, 3:16 PM
Haven't used this but looked interesting at first glance if you have multi platform ambitions https://github.com/adrielcafe/voyager
l

Landry Norris

02/27/2022, 8:52 PM
I've been using decompose for a bit, and I've liked its navigation feature. It also provides lifecycle awareness and an observable type (although, I've always found Flow more compatible with other libraries). Plus it's multiplatform.
a

Arkadii Ivanov

02/27/2022, 11:47 PM
You can try Decompose: https://github.com/arkivanov/Decompose
View count: 2