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

    Luka

    07/22/2021, 9:06 AM
    Hi. I am trying to get this layout
    a
    • 2
    • 5
  • i

    iamthevoid

    07/22/2021, 9:07 AM
    Question to compose developers (similar question like question about paddings in
    TextField
    🙂 ) Why don’t you left any possibility to change
    strokeCap
    for
    CircularProgressIndicator
    ? I can change
    strokeWidth
    [thread], but somewhy i cannot change cap
    p
    • 2
    • 5
  • s

    Sanendak

    07/22/2021, 9:10 AM
    New SplashScreen lib + Compose = bug? Or I do something wrong?
    • 1
    • 2
  • p

    Piotr Prus

    07/22/2021, 9:36 AM
    Is there a way to connect LocalProvider with the Kotlin FLow? I am trying to change dynamically the LocalProvider with DataStore flow.
    a
    • 2
    • 2
  • i

    iamthevoid

    07/22/2021, 9:42 AM
    I have a question about jetpack compose UI testing. I use side effect (LaunchedEffect) in root of my Composition. Actually this side effect subscribes on flow (just
    Boolean?
    ) to post new root in NavHostController. I use it to unauthorize user (when error 401 received from server, for example) or authorize user when it enter credentials. In app code it works perfect. But when i go through app with compose UI tests i am getting exception when user just authorized. Something like
    You can perform this action (post new root in NavController) only in main thread
    . When i dive into
    LaunchedEffect
    i found that it uses coroutines context from current composer [thread]. But for ui tests this current composer returns
    TestCoroutinesContext
    that use
    Dispatchers.Default
    instead of
    Dispatchers.Main
    . It leads that side effects crashes the app, if trying to access UI thread operations. How must i to act in this situations? Use somehow MainDispatcher directly in code (it is far from obvious)? Looks like there will be good approach to add to user the possibility to change composer dispatcher for UI tests
    • 1
    • 1
  • k

    Kefas

    07/22/2021, 11:10 AM
    Hi, is this behavior intended in Material? Why is it inconsistent?
    MaterialTheme {
        CompositionLocalProvider(
            LocalContentAlpha provides ContentAlpha.high
        ) {
            Surface(color = MaterialTheme.colors.primary) {
                LocalContentAlpha.current // 0.87 (LowContrastAlpha)
                ContentAlpha.high // 1.0 (HighContrastAlpha)
            }
        }
    }
    a
    • 2
    • 2
  • h

    Halil Ozercan

    07/22/2021, 12:14 PM
    I have a basic question about screenshotting composables. AFAIK, there are 2 main ways that one can go about this; • AndroidView->ComposeView wrapping and draw ComposeView onto a canvas • PixelCopy and directly read from window The second method is useless when composable content is bigger than the window. Any overflowing content would be lost. The first method does not have obvious blockers for getting the job done but I found a small problem. If the composable uses graphicsLayer in any way, it isn't reflected when
    composeView.draw(canvas)
    is called. All graphicsLayer modifications like
    offset
    ,
    scale
    ,
    rotation
    are disregarded. So my question is; is there a way to enable graphicsLayer while drawing a
    View
    onto a Canvas?
    ➕ 2
    • 1
    • 1
  • a

    Anton Popov

    07/22/2021, 12:38 PM
    Where is translationZ in Compose? I want to animate it, but graphicsLayer has only
    shadowElevation
    (only for shadows),
    translationX
    ,
    translationY
    s
    a
    +2
    • 5
    • 10
  • s

    SrSouza

    07/22/2021, 12:53 PM
    https://twitter.com/adrielcafe/status/1418192273435672586
    t
    • 2
    • 1
  • c

    Colton Idle

    07/22/2021, 1:07 PM
    Discussion time! For those going pure compose... Are you using Compose navigation arch component or something else? And why not just use the arch component?
    j
    s
    +2
    • 5
    • 4
  • j

    julioromano

    07/22/2021, 1:24 PM
    Has anybody tried
    navigation-compose 2.4.0-alpha05
    ? There must have been some behavior changes because my navigation logic now leads to infinite loops which didn’t happen with alpha04.
    i
    p
    • 3
    • 15
  • d

    Daniel Burnhan

    07/22/2021, 1:36 PM
    Question on converting flow to liveData. I have a class which I am using as a ViewModel (not android viewModel) which contains a flow. I get excessive collection if I pass this viewModel into the Composable view and observe the flow. I notice that if I convert to liveData in the view model instead that the excessive emission doesn't occur. Am I missing something on how this should be done?
    class MyViewModel(model: Model) {
        val userLoggedInFlow = model.usernameFlow.map { it != null } // returnes if there is a username
    }
    
    @Composable
    fun myView(viewModel: MyViewModel){
        val state = viewModel.userLoggedInFlow.asLiveData().observeAsState()
        
        if(state.value != null){
            //Show stuff here
        }
        else {
            //navigate to the login screen
        }
    }
    ➕ 1
    a
    i
    +4
    • 7
    • 17
  • a

    alorma

    07/22/2021, 6:18 PM
    Hi. Is there a way to calculate if a text (on
    Text
    ) is going to take more than a single line?
    a
    e
    • 3
    • 4
  • l

    Landry Norris

    07/22/2021, 7:57 PM
    I am currently writing a Splash Screen for an app, and I want to use this time to make a REST API call to our server that will check if the app is too outdated to properly access the API. I am currently using the single-activity model with a single Compose NavHost. I was wondering when the best time would be to trigger the viewModel to start the call. Should I trigger it when the viewModel is constructed, can the NavHost trigger the viewModel when I navigate to splash, or should I trigger this in some other way? I set up the SplashViewModel to call navigate on the navController to go to the next screen if it gets a valid response from the server.
    d
    • 2
    • 4
  • d

    Darren Lambert

    07/22/2021, 8:20 PM
    Hey guys, i try Jetpack Compose for my projet and i get a render problem when i want to preview a composable, do you have any solution to resolve this issue. Gradle Bluid: My Code:
    class MainActivity : ComponentActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContent {
                    // A surface container using the 'background' color from the theme
                    Surface(color = MaterialTheme.colors.background) {
                        Greeting("Android")
                    }
            }
        }
    }
    
    @Composable
    fun Greeting(name: String) {
        Text(text = "Hello $name!")
    }
    
    @Preview(showBackground = true,name="Text Preview")
    @Composable
    fun DefaultPreview() {
    
            Greeting("Android")
    }
    Message of the error : Attach Msg Error.txt :/
    :thread-please: 17
    a
    c
    • 3
    • 6
  • s

    Sergey Y.

    07/22/2021, 8:30 PM
    Hi. I should note that I started to notice a growing number of questions about how to turn Compose widget into a bitmap(in the manner
    View#drawingCache
    we had with legacy
    View
    system). And I didn't understand why, until now. Now I am going to raise this issue too. 😄 What I'm interested in: (see attached images 🧵) The question: Is it possible to capture the underlying layers behind the widget in order to manipulate the pixels later? Note: It is not always possible to wrap every set of composable widgets in an AndroidView and use the rendering cache in the "old" way. Is it planned to provide such functionallity with future versions of Compose(
    1.1
    ,
    1.2
    ,...)? And is it technically possible at all with Compose? Thanks.
    ➕ 1
    c
    • 2
    • 4
  • l

    Libor Bicanovsky

    07/22/2021, 9:22 PM
    Hey, is there a way to get rid of font padding within a Text element in jetpack compose? I have a Button and the text within it is slightly off center, which I assume is due to font padding. Is there an equivalent to includeFontPadding=false?
    ➕ 3
    a
    • 2
    • 1
  • c

    Colton Idle

    07/23/2021, 2:25 AM
    How do I get the size of a composable AFTER it's been laid out and measured? i.e. I want to know that my image is laid out on the screen at a final resolution of 200px x 400px.
    a
    r
    • 3
    • 4
  • m

    Mohamed Ibrahim

    07/23/2021, 3:16 AM
    hello, I’ve noticed running Compose apps in
    Android Studio Bumblebee | 2021.1.1 Canary 3
    , requires uninstalling and installing app so updates got reflected on the testing device. clicking instant run doesn’t always reflect all the changes which make it harder to debug.
    c
    d
    • 3
    • 5
  • n

    Nathan Castlehow

    07/23/2021, 4:59 AM
    Hey has anyone seen interesting behaviour where lazy lists (in our case lazy columns) recompose most of the visible items without the data changing? We are observing a calc based on the first index / first item offset to hide /show something which doesn’t look like its in the same compose scope as the list. When this value becomes stable it stops this recomposing behaviour. Theories in thread.
    i
    • 2
    • 7
  • j

    Jeff

    07/23/2021, 6:13 AM
    Hey. I want to call a ViewModel function only ONCE in a composable. e.g. viewModel.getMovies() It should not be called on re-composition. How do I achieve this?
    m
    k
    • 3
    • 5
  • t

    Tin Tran

    07/23/2021, 6:28 AM
    Hi. After upgrading to
    navigation-compose:2.4.0-alpha05
    my view model
    init {}
    is called continuously. Does anyone having the same issue? I’m using
    hilt-navigation-compose:1.0.0-alpha03
    j
    • 2
    • 23
  • d

    Dominaezzz

    07/23/2021, 7:48 AM
    Is it possible to snap an animation,
    Animatable
    or
    updateTransition
    , during the same composition? When I update the state or call
    snapTo
    , the update happens in the next frame or so.
    d
    • 2
    • 10
  • m

    ms

    07/23/2021, 7:50 AM
    Is anyone facing a crash at app startup after updating to
    Android Studio Bumblebee | 2021.1.1 Canary 4
    LOGS in 🧵
    ➕ 1
    v
    • 2
    • 2
  • j

    Jeff

    07/23/2021, 9:07 AM
    Getting this error when I upgrade to navigation-compose 2.4.0-alpha05
    java.lang.ClassCastException: androidx.navigation.NavGraph cannot be cast to androidx.navigation.compose.ComposeNavigator$Destination
    This happens when I try to navigate
    navController.navigate(Screen.Authentication.route) {
        popUpTo(Screen.Main.route) {
            inclusive = true
        }
        launchSingleTop = true
    }
    Worked fine with 04
    j
    j
    • 3
    • 9
  • d

    dbaelz

    07/23/2021, 9:36 AM
    I've posted a Compose puzzler on Twitter about multiple
    Modifier.border()
    that overdraw each other (link and code in the thread). Gave an explanation why it's this way, but after I read it again I'm unsure if it's correct and I have second thoughts. Can someone shed some light into the topic?
    a
    • 2
    • 4
  • t

    Tin Tran

    07/23/2021, 9:37 AM
    Hi. In
    LazyRow
    when I call
    animateScrollToItem
    back to a short item seems like it doesn’t animate the scroll at all. Sample code in 🧵
    a
    • 2
    • 4
  • i

    iamthevoid

    07/23/2021, 10:11 AM
    Want to create typical code input like at

    the picture from internets▾

    . What is the best option in compose to do the same? I should request user input somehow. Few years ago i did same with invisible EditText, that request focus and user input on screen start and on screen click. But it is impossible in compose.
    a
    j
    n
    • 4
    • 13
  • t

    Tgo1014

    07/23/2021, 11:09 AM
    Is there some guideline for compose code formatting already?
    a
    • 2
    • 2
  • i

    iamthevoid

    07/23/2021, 11:48 AM
    Why do different functions calling for different buttons on keyboard if i use
    LocalTextInputService
    ? If i press number (“2” for example) i got (twice!)
    onKeyEvent
    action, but when i press
    comma
    i get
    onEditCommands
    inside compose framework. Funny thing is that i can not intercept numbers pressing at all, but want that too much )
    • 1
    • 2
Powered by Linen
Title
i

iamthevoid

07/23/2021, 11:48 AM
Why do different functions calling for different buttons on keyboard if i use
LocalTextInputService
? If i press number (“2” for example) i got (twice!)
onKeyEvent
action, but when i press
comma
i get
onEditCommands
inside compose framework. Funny thing is that i can not intercept numbers pressing at all, but want that too much )
Better screenshot for
comma
case
I want to unify mechanism of user input without TextField. Has i selected correct instruments?
View count: 3