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

    Nthily

    04/08/2021, 7:32 PM
    I would like to ask, what is the latest Compose implementation of pan and rotate animation?
    d
    • 2
    • 1
  • z

    zalewski.se

    04/08/2021, 10:04 PM
    I’m trying to adjust the
    TextField
    size so it’s adjusting to the size of the text that’s currently set. I thought that
    wrapContentSize()
    would do the job but I couldn’t be more wrong 😬 So having this:
    TextField(
            modifier = Modifier.wrapContentSize(),
            textStyle = TextStyle(textAlign = TextAlign.End),
            value = text,
            onValueChange = { text = it },
            label = { Text("Label") }
        )
    Gave me such result in preview 👇 which arises 2 questions: 1. Why
    TextAlign.End
    set it around 40% of the width and what is the empty space behind it? 2. Why
    Modifier.wrapContentSize()
    doesn’t wrap it around the value or label at least? 🤔
    s
    s
    a
    • 4
    • 33
  • m

    Mark Murphy

    04/08/2021, 11:50 PM
    I've been running some experiments based on the excellent post by @Zach Klippenstein (he/him) [MOD] regarding scope of recomposition. I feel like I'm getting different results, and I'm not sure where I'm going wrong in my analysis. Details in 🧵 .
    👀 3
    s
    z
    j
    • 4
    • 29
  • c

    Colton Idle

    04/09/2021, 12:18 AM
    I updated to AS Canary 14 (no release notes?) and it prompted me to upgrade the android gradle plugin AND move to gradle 7.0 RC 1. Is that mandatory? Is anyone using gradle 7 RC 1 and any risks?
    l
    a
    • 3
    • 6
  • l

    Lilly

    04/09/2021, 12:59 AM
    I have some strange behavior. I have 2 view models which both extend from a base view model. The base view model holds state:
    var uiState: UiState by mutableStateOf(UiState.Loading)
            private set
    I also have 2 screens, each of them uses its own view model. viewModelScreenA and viewModelScreenB. When I print the uiState in both view models like:
    init {
            Timber.e("VM A - uiState: $uiState")
        }
    The uiState of both view models are identical
    UiState$Loading@220c954
    . I would expect that they are different, not?
    e
    i
    • 3
    • 8
  • e

    elye

    04/09/2021, 9:28 AM
    Should I use
    FloatTweenSpec
    or
    tween<Float>
    , …
    FloatSpringSpec
    or
    spring<Float>
    ?
    ➕ 1
    c
    d
    • 3
    • 7
  • e

    escodro

    04/09/2021, 12:40 PM
    Hello, everyone! 👋 I’m facing some issues with Compose and SplitScreen support. When my application first loads in Split Screen, it works fine. But if I try to resize it, the UI no longer loads. If I resize for a second time, it loads again. Basically, the first resize does work, the second does not, the third does works and goes on. Is it a Compose issue? Am I doing something wrong? Could someone help me, please? Thanks a lot in advance. ❤️
    m
    a
    p
    • 4
    • 20
  • n

    nglauber

    04/09/2021, 1:33 PM
    I noticed a problem with
    tryAwaitRelease()
    on beta04. It’s always returning false… 🤔
    z
    • 2
    • 4
  • n

    Nat Strangerweather

    04/09/2021, 4:40 PM
    I've got yet another problem, sigh... I have a rectangle that covers the whole canvas. I am using detectTapGestures to detect presses. When I press somewhere within the rectangle, I only get success some of the time - it's really inconsistent. I have no idea what is wrong with my simple code. Any ideas? Code in thread.
    k
    g
    • 3
    • 10
  • d

    dewildte

    04/09/2021, 6:06 PM
    Has anyone ran into the Bottom Sheet automatically expanding in the
    BottomSheetScaffold
    ? Video of the erroneous behaviour in the thread.
    c
    • 2
    • 5
  • g

    Gabriel

    04/09/2021, 7:43 PM
    What version of
    kotlin-gradle-plugin
    are we meant to be using? I'm on 1.4.32 and experiencing some ... issues
    c
    • 2
    • 2
  • i

    izyaboi

    04/09/2021, 10:25 PM
    one question how can i bind a service before setcontent in MainActvity? i have a exoplayer instance i create in service. and want to give ist to my mainscreen in the set content in oncreate? i implement the way google recommend but in oncreate my player instance is every time null
    a
    • 2
    • 22
  • r

    rnett

    04/10/2021, 3:28 AM
    ClickableText does not seem to work inside of SelectionContainer. I assume this a bug? I'm fairly sure it was working at one point (pre-beta).
    r
    • 2
    • 1
  • r

    rnett

    04/10/2021, 4:43 AM
    Is there a way to get the marker annotations (particularly
    @Immutable
    ) in a separate, common artifact? I have some data definitions in a common module that doesn't have compose dependencies, and would like to mark them as immutable.
    j
    a
    z
    • 4
    • 4
  • o

    orangy

    04/10/2021, 11:19 AM
    How do you set the maximum value for a manually-controlled scroll? I can’t set the
    maxValue
    on
    ScrollState
    because it’s internal… I’m using
    verticalScroll
    modifier on my component, but can’t figure out how to set its limits…
    a
    m
    • 3
    • 5
  • o

    Olivier Patry

    04/10/2021, 12:22 PM
    I have a (quite) complex composable compound of several pieces modifying a common state. I'd like to avoid giving plenty of callbacks everywhere in favor of centralizing such logic in a "state" object consumed by all my composables. I can't make it work so far. I think I read somewhere how to deal with that, to avoid tons of
    value, onValueChanged: () -> Unit
    , extract it in a "state". Does it ring a bell to someone? Any advice on how to manage my use case? (I can detail more if needed)
    r
    • 2
    • 3
  • o

    orangy

    04/10/2021, 1:03 PM
    I have a custom
    Layout
    component, that does all the measurements and placements. Now, I want to draw some adornments on the canvas, kinda like
    drawBehind
    , but I need to know placements of the children. How would I do it?
    • 1
    • 2
  • p

    Paul Woitaschek

    04/10/2021, 7:23 PM
    One thing I'm having really difficulties with compose is naming. How do I name my things? Let's say I have a counter: Intuitively, I'd create a function called:
    @Compsable fun Counter()
    But now I need to separate the logic and UI and need to create a counter class that is the actual counter and not the ui. Intuitively I'd call that counter
    class Counter
    . Now having both of these named the same is obviously a bad idea, but what's the solution to this? Consistently suffixing every composable ui function as
    CounterUI
    ? Or
    CounterView
    ? How do you handle this?
    ➕ 1
    a
    c
    +6
    • 9
    • 27
  • z

    Zhelyazko Atanasov

    04/11/2021, 5:29 AM
    Any idea why "Deploy Preview" button of a
    @Preview
    is grayed out and inactive? Using AS Canary 14 with Compose
    beta04
    (tried
    beta03
    - same thing). Is this a known issue?
    j
    c
    • 3
    • 4
  • l

    loloof64

    04/11/2021, 10:14 AM
    Hi ! Looking at https://developer.android.com/jetpack/compose/state, it is written that we may need to create custom object saver to pass custom data to
    rememberSaveable
    , but how should I build such object ? Let's say for
    data class Point(val x: Int, val y:Int)
    ? Because there is not any example in the documentation, and I did not understand this sentence (
    build a custom object saver
    ), what interface should the saver have ? What is the Android class/object responsible for such interface ? Should I create a
    Bundle
    myself ?
    j
    a
    • 3
    • 11
  • s

    Slackbot

    04/11/2021, 2:04 PM
    This message was deleted.
    n
    • 2
    • 3
  • o

    orangy

    04/11/2021, 4:52 PM
    I see that many people do games with Compose, including myself :) may be we need #compose-gamedev? I’m not totally sure, just asking for crowd wisdom. #gamedev looks too broad. Or may be not?
    a
    s
    m
    • 4
    • 4
  • p

    Paul Woitaschek

    04/11/2021, 7:07 PM
    I'm running in a kind-of state problem. I have an audiobook player. On the playback screen I show a Slider with the current position in the chapter. The backing state periodically emits with the current position. So for the slider value, I can't just use remember, else while playing, the track would not be updated. Instead I have passed the current time as the key to the remember function. In theory this works. However when you try to seek while on playback, the slider continues to be updated which causes visual glitches. Any idea how I can come around that? Here is my current implementation: https://github.com/PaulWoitaschek/Voice/blob/aad9fd7eafe734e739b7e20e4d908f242a95ce51/playbackScreen/src/main/java/voice/playbackScreen/views/PlaybackSlider.kt
    z
    r
    k
    • 4
    • 3
  • a

    andbapps

    04/11/2021, 8:38 PM
    I'm having some weird behavior with
    IntrinsicSize
    and
    Arrangement.SpacedBy
    (code in thread)
    • 1
    • 3
  • j

    james

    04/12/2021, 12:14 AM
    has anyone seen decent examples of master/detail apps built with Compose? looking at building something which I’d like to run on both phones and tablets with a slightly enhanced tablet view. last time I had to do this was before Android Architecture components even existed (so pre-ViewModel etc).. I’m wondering if anyone has seen anything with a master/detail tablet view which is using modern architecture, and specifically Compose?
    i
    a
    • 3
    • 7
  • l

    Lilly

    04/12/2021, 1:37 AM
    I'm looking for a specific function that allows to make multiple changes to a state before recompose is triggered. I can't find it. Can someone help?
    a
    • 2
    • 2
  • j

    Jason Ankers

    04/12/2021, 3:39 AM
    Is it possible to configure a LazyColumn/Row to always snap to discrete item positions after a scroll? It looks like this was possible previously with
    FlingConfig
    (now
    FlingBehaviour
    ?) but I cant see how I can specify a list of anchors or snap points easily
    a
    p
    • 3
    • 5
  • s

    Shivam Sethi

    04/12/2021, 5:44 AM
    help composers, why this is not animating ? I put log statement which gets printed with the changing float values (1f to 1.5f)
    s
    g
    b
    • 4
    • 6
  • a

    Abhishek Dewan

    04/12/2021, 6:19 AM
    Wrote about my experience using Compose to write an animated collapsable button (https://abhishekdewan101.github.io/learning-to-code/blog/Animating/). Compared to the old system, I found the way of thinking of animation in compose easier to get used to.
    👏 1
    :jetpack-compose: 1
    • 1
    • 1
  • a

    allan.conda

    04/12/2021, 9:17 AM
    Has anyone been able to successfully return a result of a navigation from
    compose-navigation
    ? I could get the results from
    NavBackStackEntry.savedStateHandle
    , but I’m not sure where that code belongs… Do you pass it as state? https://github.com/android/compose-samples/blob/main/Owl/app/src/main/java/com/example/owl/ui/NavGraph.kt#L75-L85
    i
    • 2
    • 3
Powered by Linen
Title
a

allan.conda

04/12/2021, 9:17 AM
Has anyone been able to successfully return a result of a navigation from
compose-navigation
? I could get the results from
NavBackStackEntry.savedStateHandle
, but I’m not sure where that code belongs… Do you pass it as state? https://github.com/android/compose-samples/blob/main/Owl/app/src/main/java/com/example/owl/ui/NavGraph.kt#L75-L85
i

Ian Lake

04/12/2021, 2:09 PM
savedStateHandle.getLiveData("key").observeAsState()
We talk more about state from LiveData, etc. in the state guide: https://developer.android.com/jetpack/compose/state#use-other-types-of-state-in-jetpack-compose
a

allan.conda

04/12/2021, 4:21 PM
I see. So it's basically treated just like any other state.
View count: 1