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

    Rafs

    01/03/2021, 11:42 AM
    What is the recommended way of drawing text inside a 
    Canvas
     composable since there is no 
    drawText
     method. I have a requirement where I rotate the canvas and draw some lines with some text. I'm currently using 
    drawContext.canvas.nativeCanvas.drawText
    d
    • 2
    • 1
  • d

    dimsuz

    01/03/2021, 12:38 PM
    Hi! When using compose in a multi-module project do I have to specify
    composeOptions
    +
    useIR = true
    +
    buildFeatures.compose = true
    for each module or is it enough to specify all (or some) of these in the
    :app
    module? Setup instructions have only app module example (which unfortunately is true for many examples in docs: they assume a single app-module structure)
    b
    • 2
    • 1
  • a

    Ayomide

    01/03/2021, 2:58 PM
    Hey, I'm trying out Ktor's WebSocket client library. It returns incoming messages from a web socket as a
    SharedFlow
    - I'm trying to figure out how to keep the web socket session (
    DefaultClientWebSocketSession
    ) running in the background so that I can collect the
    SharedFlow
    messages and display them on screen as they stream in into a
    LazyColumn
    or similar. I'm not sure how to fit this into Compose's state tools. I tried using
    coroutineScope.launch{}
    with
    rememberCoroutineScope()
    but it seems like the web socket session would stop as soon as the coroutine scope ended.
    a
    • 2
    • 2
  • n

    nglauber

    01/03/2021, 8:14 PM
    hey! I’m playing with BottomNavigation and Jetpack Navigation and I did an sample based on @Afzal Najam post ( thanks man🙏 https://afzaln.com/multiple-navigation-graphs-with-jetpack-compose-navigation/) Here’s my code: https://gist.github.com/nglauber/5061cbbafd63488131380b09c8943ad7 I have two questions: 1. When the second tab is selected and displaying its root content, is there a way to display the first tab when the user presses the system back key? 2. Could someone point out where can I find a way to save the
    LazyColumn
    scroll position? In my sample, the first tab is a list.
    a
    k
    +2
    • 5
    • 13
  • v

    Vivek Sharma

    01/04/2021, 6:17 AM
    drawLine(
        brush = SolidColor(Color.Red),
        cap = StrokeCap.Round,
        strokeWidth = 8.dp.toPx(),
        start = middle,
        end = Offset(midX, 16.dp.toPx())
    )
    Can anyone help me with this, when we draw a line using the above code,
    end
    mean we ending that line at some position, But with
    Offset(X,Y)
    Y having
    16.dp.toPx()
    what does this mean? I am increasing Y offset like
    100.dp.toPx()
    , line is becoming short in length Why?
    v
    • 2
    • 3
  • j

    Jeff

    01/04/2021, 8:05 AM
    Does anyone talk about the performance of Jetpack Compose? I have tried various samples e.g JetNews and the scrolling, behavior and transitions of different elements does not match native elements like RecyclerView. Is this expected because compose is not fully native?
    ➕ 1
    m
    s
    +5
    • 8
    • 15
  • g

    Geert

    01/04/2021, 9:02 AM
    What is the latest compose version? I was using alpha09, but Android Studio mentioned that SNAPSHOT was available. Can’t find any release notes, and isn’t SNAPSHOT before alpha?
    c
    • 2
    • 1
  • a

    André Thiele

    01/04/2021, 10:04 AM
    Is there an option in AS Canary to automatically refresh Compose previews?
    k
    v
    • 3
    • 6
  • m

    Marko Novakovic

    01/04/2021, 11:24 AM
    In the past convention was to put
    Modifier
    as a first parameter of a
    composable
    . Did it change? Am seeing more and more samples, including Google ones, with
    Modifier
    as the last parameter. Where it "should be" put?
    f
    • 2
    • 3
  • n

    nicola.de.fiorenze

    01/04/2021, 1:38 PM
    Hi, can someone help me? How can I set the cursor position in a text field? The equivalent of
    editText.setSelection(position)
    with the classic android view system. thanks
    a
    • 2
    • 2
  • c

    Colton Idle

    01/04/2021, 5:41 PM
    My first screen that I did in compose! The entire fragment is only ~70 lines long, but I don't think it's idiomatic. Can anyway take some time to critique? https://gist.github.com/ColtonIdle/85db918c763076cbb147b722e6807007
    a
    • 2
    • 11
  • l

    Lauren Yew

    01/04/2021, 9:03 PM
    Question about
    mutableState
    and
    State
    : in the "Using State in Jetpack Compose" codelab, it says:
    State<T> is intended to be used by Compose.
    
    Application state that's used outside of Compose should not use State<T> to hold the state.
    Why is this? Is
    State
    being discarded along with the compose-recompose lifecycle or something? Does anyone know the lifecycle of
    State
    ?
    ➕ 1
    j
    s
    +2
    • 5
    • 12
  • l

    Lauren Yew

    01/04/2021, 9:49 PM
    Having issues with Compose
    TextField
    sometimes opening keyboard properly when I click on the textfield, and sometimes not. Is anyone else seeing these issues? Working thru "Using State in Jetpack Compose" codelab
    s
    s
    • 3
    • 2
  • m

    Mehmet Peker

    01/05/2021, 1:52 AM
    Hello everyone,im trying detect swipe direction in compose.Im using draggable modifier for this.But draggable allows only one direction to detect(Vertical or Horizontal).I want to detect swipe for all direction(left,right,up,down).May anyone help me how can i do this?Thanks.
    t
    • 2
    • 3
  • k

    Kshitij Patil

    01/05/2021, 10:43 AM
    If one of the items in a Row is using
    fillMaxHeight
    and one of the item's height is conditionally dependent upon some state, don't we have any other option than writing a custom layout to get wrapContent behaviour? Currently
    fillMaxHeight
    makes the row fill the entire height but what I meant was the maximum height of an item in given row
    y
    • 2
    • 3
  • k

    Kshitij Patil

    01/05/2021, 11:18 AM
    How can we add a custom scroller to
    LazyColumn
    ?
    • 1
    • 1
  • r

    rsktash

    01/05/2021, 12:51 PM
    Is there any rule for posting? Big chunks of codes and error logs are irritating. We could use gist or something else
    j
    h
    • 3
    • 2
  • k

    Kshitij Patil

    01/05/2021, 1:04 PM
    Is it possible to use compose for Custom Snackbar Layout which to be used with lagacy xml based Fragment?
    • 1
    • 1
  • k

    Kshitij Patil

    01/05/2021, 1:48 PM
    When to use
    ScrollableColumn
    vs
    LazyColumn
    ? Is it equivalent to RecyclerView vs ListView?
    :yes: 1
    s
    p
    +3
    • 6
    • 7
  • v

    Vitor Prado

    01/05/2021, 3:58 PM
    hey guys, can you help me with this simple question: How can I check for “preview” state inside composable? Can I know when the view is rendering in preview environment?
    k
    j
    c
    • 4
    • 9
  • n

    Nat Strangerweather

    01/05/2021, 4:50 PM
    What would be the best way of linking a broadcast receiver to a Composable? At first I thought the best idea would be to use a live data / android viewmodel scenario, but this does not seem to work (unless I am doing it wrong): my values are always null on arrival. I also tried to simply pass the broadcast receiver data into a function and send that to my Composable. My values are updated when I use the function (using a Toast message) outside the Composable, but not when I pass the values to the Composable. Any ideas?
    ✅ 1
    • 1
    • 1
  • m

    Marcello Galhardo

    01/05/2021, 5:23 PM
    What is considered the best way to connect a ViewModel to a Composable? Using a "mutable"
    StateFlow
    or
    LiveData
    that is "collected as state" and receive new values directly (e.g.,
    onChanged = { vm.stateFlow.value = it }
    or creating a "local remembered state" and passing it back only when necessary (e.g.,
    onClick = { vm.onClick(myRememberedState.value) }
    ). 🤔
    ➕ 2
    n
    n
    • 3
    • 2
  • b

    buszi0809

    01/05/2021, 6:15 PM
    I'm tryna use Jetpack Compose with latest 1.0.0-alpha09 version and I can't find @Preview. Did they delete it?
    m
    b
    m
    • 4
    • 24
  • j

    Javier

    01/05/2021, 6:23 PM
    The usage of
    android:configChanges
    with some flags (
    orientation
    for example) will be the standard in the future? I think that Compose can manage better the responsibility. In case of an affirmative reply, extending the ViewModel should be useless?
    🙌 2
    s
    a
    s
    • 4
    • 7
  • l

    Lilly

    01/05/2021, 6:36 PM
    When I try to preview a composable I get Render problems, but I can't figure out what the problem is about:
    @Preview
    @Composable
    fun TestPreview() {
        Text("Hello World!")
    }
    I'm on alpha09 with latest IDE.
    stacktrace
    j
    • 2
    • 8
  • l

    Leandro Garcia

    01/05/2021, 6:45 PM
    Hello, I'm getting started with compose and was looking at
    LazyColumn
    and
    LazyColumnFor
    when should one or the other be used? I see that
    LazyColumnFor
    calls
    LazyColumn
    internally
    z
    c
    • 3
    • 4
  • c

    Colton Idle

    01/05/2021, 7:32 PM
    Has anyone gotten compose to work in an application with proguard? Looks like my app wont launch anymore due to enabling compose. I'm not 100% sure it's composes fault yet, but it's the most glaring change so far.
    j
    e
    • 3
    • 5
  • m

    Matt Lien

    01/05/2021, 8:03 PM
    Is there a known issue with using TextOverflow.Ellipsis and TextAlign.Center together with the text sometimes getting cut off? I tried searching for a related issue but didn't find one, so wanted to check if anyone else has ran into the same thing.
    s
    • 2
    • 5
  • c

    Colton Idle

    01/05/2021, 9:26 PM
    https://twitter.com/tikurahul/status/1346562479204126720 I see compose compiler is taking contributions on github and after digging into the repo, it seems that compose is also hosted there? Or am I interpreting it wrong and it's on the compose compiler?
    j
    • 2
    • 3
  • l

    Lilly

    01/06/2021, 3:06 AM
    It seems that 
    @Preview
     is not able to preview drawables. Can s.o. confirm that? Is this a known bug?
    ListItem(
            text = { Text("") },
            icon = { Icon(vectorResource(id = iconRes)) }, // can not be previewed
        )
    While 
    iconRes
     is a png file. EDIT: Sorry, wasn't aware of
    imageResource
    . Now it works.
    ✔️ 1
    n
    • 2
    • 1
Powered by Linen
Title
l

Lilly

01/06/2021, 3:06 AM
It seems that 
@Preview
 is not able to preview drawables. Can s.o. confirm that? Is this a known bug?
ListItem(
        text = { Text("") },
        icon = { Icon(vectorResource(id = iconRes)) }, // can not be previewed
    )
While 
iconRes
 is a png file. EDIT: Sorry, wasn't aware of
imageResource
. Now it works.
✔️ 1
n

Nader Jawad

01/06/2021, 7:36 AM
In the latest alpha we introduced the
painterResource
API that opaquely loads pngs or vector assets and returns a Painter that can be used as input to the Icon composable
View count: 2