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

    Marcin Środa

    07/22/2020, 8:25 AM
    How to get current item position / scrolling position in LazyColumnItems? Should I implement custom scrolling modifier? I want to hold current item position while loading more data before (working on something like chat list with fetching old messages while scrolling to the edge) and need to know what position is (like in vertical scroller).
    c
    a
    • 3
    • 4
  • t

    tonnyl

    07/22/2020, 10:11 AM
    Hi all, Is there a way to set
    app:liftOnScroll="" 
    app:liftOnScrollTargetViewId=""
    for AppBarLayout in Compose ?
    c
    • 2
    • 1
  • t

    Timo Drick

    07/22/2020, 10:56 AM
    Some of my vector drawables get converted to png images during apk compilation. (I assume that is because they contain features only supported in api >= 24) That is fine but when i use vectorResource(id=...) than it works only in api levels >= 24 and in api levels < 24 i have to use imageResource(id=...) What is the recommended way of doing this things?
    c
    • 2
    • 4
  • a

    Archie

    07/22/2020, 11:50 AM
    Hi, I was trying out compose and was wondering about its lifecycle and how to deal with it and its gotchas. The only place I found for documentation was this right here: https://foso.github.io/Jetpack-Compose-Playground/general/compose_lifecycle/ I was wondering if there was more. Or maybe its too early for this?
    a
    • 2
    • 4
  • a

    Archie

    07/22/2020, 1:35 PM
    I was also wondering if it is possible to run
    Coroutines
    with compose?
    :yes: 3
    a
    t
    • 3
    • 17
  • t

    Timo Drick

    07/22/2020, 2:08 PM
    I just noticed a big APK size increase from dev13 to dev14. So problem is that many appcompat libs get now included. (I run minify to opimize output APK) The minimal archiveable APK size was about 600 KB with a simple HelloWorld sample. Now with dev 14 it is about 1.1 MB. Not sure if this is a bug? So i could provide a sample project and file a bug report.
    a
    c
    • 3
    • 7
  • t

    tcracknell

    07/22/2020, 5:20 PM
    Hello! The latest Jetpack Compose minor release, dev15, has just been released! You can get it now on Google’s Maven Repository. Release notes are available at https://developer.android.com/jetpack/androidx/releases/compose and https://developer.android.com/jetpack/androidx/releases/ui. Please note: 1) The Kotlin version has been updated and you will need to update your build.gradle file. 2) There was a major refactoring of the artifacts in this release and you can find the updated mapping in the release notes. Thanks!
    🔥 2
    🎉 22
    👍 4
    j
    z
    +9
    • 12
    • 27
  • t

    Tomáš

    07/22/2020, 6:16 PM
    Hey I’m having some issues working with TextField()
    Column(Modifier.padding(innerPadding).fillMaxSize()) {
        var textState by state { TextFieldValue("test") }
        TextField(
            value = textState,
            onValueChange = { textState = it },
            modifier = Modifier.fillMaxWidth().preferredHeight(240.dp)
        )
    }
    But the “test” text is not editable, as soon as I try to type something - nothing happens and then I get leak from leak canary 😞 Any ideas?
    d
    • 2
    • 2
  • h

    Halil Ozercan

    07/22/2020, 7:40 PM
    What is the right way of finding the size of a
    Box
    after it is created? Or any other
    Composable
    for that matter?
    p
    z
    l
    • 4
    • 8
  • b

    Ben

    07/22/2020, 8:52 PM
    Is there any sample up to date with constraint layout & compose?
    h
    l
    r
    • 4
    • 4
  • d

    doodla

    07/22/2020, 11:50 PM
    is there a compose way to do viewpagers/bottom navs?
    t
    • 2
    • 2
  • m

    Madhava

    07/23/2020, 12:25 AM
    Trying to update an old dev14 project:
    > Task :app-lifelike:processDebugResources FAILED
    Execution failed for task ':app-lifelike:processDebugResources'.
    > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$Action
       > 1 exception was raised by workers:
         com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-4.2.0-alpha05-6645012-osx Daemon #0: Unexpected error during link, attempting to stop daemon.
         This should not happen under normal circumstances, please file an issue if it does.
    Dependent features configured but no package ID was set.
    I can't find anything that explains what the actual problem is
    l
    i
    • 3
    • 3
  • m

    Madhava

    07/23/2020, 2:17 AM
    @Zsolt https://github.com/zsoltk/compose-router/pull/35 Any chance you can explain how I can fix the unchecked cast warnings for my PR on compose-router?
    l
    • 2
    • 10
  • g

    galex

    07/23/2020, 4:03 AM
    Hello, this is going to stay isn’t? Any way around it?
    e: /Users/galex/projects/alexpizzapp/app/src/main/java/il/co/galex/alexpizzapp/common/navigation/Navigation.kt: (24, 16): @Composable invocations can only happen from the context of a @Composable function
    I can reference
    Icons.Filled.AccountBox
    but I can’t call to
    vectorResource
    at the same level 😞
    l
    • 2
    • 7
  • m

    Mehdi Haghgoo

    07/23/2020, 5:30 AM
    Hi. Is material theme the only way to create a theme for a Compose app?
    r
    • 2
    • 2
  • a

    AG

    07/23/2020, 5:37 AM
    Hello, is there any way to disable text selection on long tap?
    l
    • 2
    • 3
  • j

    Joost Klitsie

    07/23/2020, 7:53 AM
    Hi all, is there a reason why the component functions start with a capital letter? I would expect normal camelCase like
    outlinedTextField
    instead of
    OutlinedTextField
    as most function calls in Kotlin in the std or wherever do it like that. I would think uppercase is better fitting for classes, which is not fitting for composable functions 🙂
    g
    • 2
    • 2
  • m

    Mehdi Haghgoo

    07/23/2020, 8:51 AM
    It's weird. When working with a Compose app, Android Studio 4.2 Canary 5 exhausts almost all the available physical RAM (8GB) on my (Linux) machine and then it quits after a phase of hanging. Attaching a screenshot.
    g
    t
    • 3
    • 4
  • g

    galex

    07/23/2020, 12:41 PM
    Is there an example on how to use the new Activity Results API with Compose? I'd like to do a Google sign-in from a Composable and would rather not pass down something from the Activity all the way down to the Composable
    j
    r
    • 3
    • 9
  • b

    Bacho Kurtanidze

    07/23/2020, 1:38 PM
    how can I test MutableState? I cant create its instance globally. it only works inside of setContent block, but even when I do create it locally, when its called by some function which isnt annotated by @Composable it throws java.lang.IllegalStateException: Not in a frame.
    a
    • 2
    • 3
  • a

    Archie

    07/23/2020, 1:39 PM
    Is there a way to integrate
    Navigation Component
    in
    Compose
    without using
    Fragments
    ?
    i
    c
    • 3
    • 3
  • g

    galex

    07/23/2020, 2:58 PM
    What about Hilt ? 😄 (dislaimer: didn’t try it yet, will do soon)
    a
    z
    +4
    • 7
    • 36
  • d

    Daniel Rampelt

    07/23/2020, 2:58 PM
    I'm having some trouble getting previews to work with the latest versions, last time I tried compose was with dev05 and I didn't have any issues. Project builds and runs fine on a device, it's just previews not working. I'm using AS 4.2 Canary 5 and compose dev15, getting this error in the preview pane (I'll post the full stack trace in a thread):
    The following classes could not be instantiated: - androidx.ui.tooling.preview.ComposeViewAdapter
    👀 2
    m
    b
    +3
    • 6
    • 10
  • t

    Timo Drick

    07/23/2020, 3:07 PM
    Just started open beta test for my Wallpaper App. The UI is exclusive Compose. Single Activity no Fragments. It is still work in progress and compose version dev14. Please try it and report problems. If you have any questions how i implemented s.th. i am looking forward to explain it and share code with you. https://play.google.com/apps/testing/de.appsonair.fanart Did not have any compose based app with big user base now. So i do not know if there are some problems. In theory it should run on all devices since Android API 21
    h
    a
    • 3
    • 8
  • m

    MBegemot

    07/23/2020, 4:01 PM
    Hi timo, why don't just use a google drive link like https://drive.google.com/file/d/1p647P0bOjpoqZtDZQEwu-9bIZmyleibn/view?usp=sharing it's easier specially at early stages, you can check it if you wish it's an app for language students , still in alfa.
    t
    • 2
    • 1
  • z

    Zach Klippenstein (he/him) [MOD]

    07/23/2020, 4:21 PM
    With this change that landed yesterday (https://android-review.googlesource.com/c/platform/frameworks/support/+/1369437), it looks like the API for entering Compose from classic Android Views is moving away from
    setContent
    extension functions to the dedicated
    AbstractComposeView
    and
    ComposeView
    classes. Is the
    ViewGroup.setContent
    extension potentially going away as well? If so, will there still be a way to pass `CompositionReference`s to compositions hosted inside android views? (This issue: https://issuetracker.google.com/issues/156527485)
    l
    a
    • 3
    • 11
  • r

    Ricardo C.

    07/23/2020, 4:30 PM
    Why are we getting indexed variants for lazy composables instead of adding index to the existing ones? https://android-review.googlesource.com/c/platform/frameworks/support/+/1364679
    l
    a
    +2
    • 5
    • 25
  • h

    Halil Ozercan

    07/23/2020, 7:41 PM
    I see that with dev15,
    Transition
    composable is deprecated in favor of
    transition
    which is highly similar but instead of receiving children as a trailing lambda, it provides a state that can be used by following composables in the same scope. The docs suggest that
    toState
    is the main control unit for transition state. Whenever it changes, animation will change the course to this new destination state whether the animation was running or not. However, I'm having trouble understanding how to reset the current animation all together. Let's say my initial configuration is to go from
    A
    to
    B
    . In the middle of this transition, Composable receives a new state, which means the animation needs to restart. Animation should go back to state
    A
    and again head for
    B
    . I could not find a way of simply resetting
    initState
    and
    toState
    at the same time. What is the recommendation for such behavior?
    i
    d
    • 3
    • 8
  • c

    chris

    07/23/2020, 7:45 PM
    When working with state on a mutable object even if I tell the state that it is
    NeverEqual
    to invoke the comparison of the objects to trigger a recompose I still have to call the setter. So I end up assigning the object to itself. Am I missing another way to do this?
    z
    • 2
    • 2
  • z

    Zach Klippenstein (he/him) [MOD]

    07/23/2020, 8:24 PM
    Does a
    CompositionLifecycleObserver
    that enters a composition by being captured by a composable lambda get its callbacks invoked? E.g.
    class MyActivity : AppCompatActivity() {
      private val myObserver: CompositionLifecycleObserver = object : …
    
      override fun onCreate() {
        setContent { MyApp(myObserver) }
      }
    AFAIK the only way an observer can be “registered” is by being returned from
    remember {}
    .
    🤔 1
    l
    a
    • 3
    • 4
Powered by Linen
Title
z

Zach Klippenstein (he/him) [MOD]

07/23/2020, 8:24 PM
Does a
CompositionLifecycleObserver
that enters a composition by being captured by a composable lambda get its callbacks invoked? E.g.
class MyActivity : AppCompatActivity() {
  private val myObserver: CompositionLifecycleObserver = object : …

  override fun onCreate() {
    setContent { MyApp(myObserver) }
  }
AFAIK the only way an observer can be “registered” is by being returned from
remember {}
.
🤔 1
l

Leland Richardson [G]

07/23/2020, 9:11 PM
Unfortunately it’s a little bit harder to define than that. If you are relying on it, use remember
it can also happen by being passed as a parameter
👍 1
a

Adam Powell

07/23/2020, 9:29 PM
also useful to know is that if an object that implements CLO is remembered in several places, it won't leave the composition until it leaves everywhere, including all of the cases of remembered parameters for restarting composable function calls.
if you want to know for sure if a specific composable function call has left the composition by way of a CompositionLifecycleObserver, don't let the reference to the actual CLO object escape to user code.
View count: 1