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

    Pavle Joksovic

    05/20/2022, 8:32 AM
    I have Column that consists of Text (aligned to the top of the screen) Scrollable Text (placed between the top text and bottom button) Button (aligned to the bottom of the screen) What is the easiest way to implement this? If I just place it in a Column the scrollable text pushes the button below the visibility of the screen.
    o
    h
    3 replies · 3 participants
  • g

    Guilherme Delgado

    05/20/2022, 1:45 PM
    I have a Column with
    verticalArrangement = Arrangement.SpaceBetween
    and if it’s
    Surface
    parent defines
    .fillMaxSize()
    , the Column’s height is not respected. More in thread
    a
    15 replies · 2 participants
  • a

    allan.conda

    05/20/2022, 1:46 PM
    What’s the correct way to update an AndroidView when the Theme/Configuration changes? The view doesn’t update when changing Light/Dark theme
    c
    m
    6 replies · 3 participants
  • v

    Vaios Tsitsonis

    05/20/2022, 2:03 PM
    is there any way to animate between two textstyles?
    k
    c
    +3
    15 replies · 6 participants
  • a

    agrosner

    05/20/2022, 3:01 PM
    Testing - the official docs on compose recommend we run AndroidTest for our composables that run on a device. Also i have seen people mention robolectric in this channel to run a bunch of tests quickly. We have a lot of modules in our company and CI would not efficiently handle all of the tests to run often on PRs with many or any emulators. 1. should we use robolectric even if its not perfect? 2. is there movement on making official headless compose unit tests that dont need a physical device (outside of robolectric) to verify basic ui interactions or snapshots
    m
    d
    12 replies · 3 participants
  • m

    manju reddy

    05/20/2022, 4:57 PM
    Hello All, I am looking at Textfields and I dont see a way to set Overflow for Text. Is there a way we set overflow with type ellipse.
    a
    c
    5 replies · 3 participants
  • m

    mertceyhan

    05/20/2022, 5:22 PM
    Hi all! I have full-screen BottomSheetScaffold content and I want to make it scrollable inside the bottom sheet. I’ve seen this custom implementation but is there any support from the framework itself?
    s
    j
    +1
    11 replies · 4 participants
  • n

    Nat Strangerweather

    05/20/2022, 8:20 PM
    Is it possible to overlap two elements in a Surface, and for them to both be centred? With my current code, one element pushes the other one to the top left. I was expecting both to be stacked in the centre... I know I can do that with a Box, but I have to use a Surface. More in thread.
    m
    c
    15 replies · 3 participants
  • j

    Ji Sungbin

    05/21/2022, 8:00 AM
    Wouldn’t memory leak if Context is provided as CompositionLocal like LocalContext(activity context by owner.context)? CompositionLocal values store in SlotTable, I know that SlotTable is just a linear array. In the case of an activity context, entering the array is a potential memory leak. Let me know if I’m misunderstood.
    👍 3
    a
    2 replies · 2 participants
  • j

    Ji Sungbin

    05/21/2022, 8:01 PM
    Hi, if invalidation occurs, it is recorded in
    invalidateStack
    , and if this stack is not empty, it is popped from this stack and returned from
    endRestartGroup()
    . Recomposition is performed through the returned
    RecomposeScope
    . Right? However, if there is no invalidation during the composition process, null is returned, and if invalidation is requested later, how does
    endRestartGroup()
    detect this and recompose again? If look at the implementation of
    endRestartGroup()
    , there is no code to track invalidations. Only request pop once.
    val scope = if (invalidateStack.isNotEmpty()) invalidateStack.pop() else null // RecomposeScopeImpl?
    EDIT: I found some clues. Suspend until invalidation is added through
    awaitWorkAvailable()
    in
    Recomposer.runRecomposeAndApplyChanges()
    . If there is a waiting task(
    hasSchedulingWork
    ), it immediately resumes
    Continuation
    and proceeds to recompose. Otherwise, it maintains the suspend state. The maintained suspend(
    CancellableCoroutine
    ) is resumed when the operation is completed through the
    effectJob
    , but as I traced the places where the
    effectJob
    is used, there are only
    rememberCoroutineScope()
    and
    LaunchedEffect
    . Where will this suspend resume? I think it’s time to record invalidation, but it wasn’t. They are recorded regardless of
    Job
    .
    a
    4 replies · 2 participants
  • e

    Eko Prasetyo

    05/22/2022, 4:31 AM
    Hi guys, So basically I have all my UI state encapsulated in a single data class and expose it to the composable UI via single state flow. If I want to modify the state I use
    _state.value = _state.value.copy(...)
    . Does something like this should be avoided or affecting performance?
    j
    m
    +3
    11 replies · 6 participants
  • s

    shahroz

    05/22/2022, 8:51 AM
    Hey folks, is there any way to open full keyboard in landscape mode? like it used to prior-compose? because right now it opens the same in portrait/landscape mode
    z
    s
    3 replies · 3 participants
  • u

    Uli Bubenheimer

    05/22/2022, 8:10 PM
    For what reason does snapshotFlow() mix the concept of state updates with the concept of equality? I can easily say snapshotFlow().distinctUntilChanged() if I really want to check equality, but in the present system I cannot easily observe state updates where the evaluation result does not change in terms of equality, e.g. with SnapshotStateList (would have to make explicit list copies). Seems poorly thought out.
    f
    a
    45 replies · 3 participants
  • x

    xxfast

    05/23/2022, 12:53 AM
    Hi all. I'm trying to achieve this animation but running into an issue (as you can see) where the fabs flashes out-of-bounds. Full
    @Composable
    in the 🧵
    a
    r
    +1
    12 replies · 4 participants
  • z

    Zoltan Demant

    05/23/2022, 5:46 AM
    Has anyone had any issues with composables being laid out in the incorrect positions (under extremely rare, but reproducible scenarios)? Issue & details in 🧵
    1 reply · 1 participant
  • a

    Alexander Stark

    05/23/2022, 6:10 AM
    Hi there, I'm struggling with a challenge. I have two text fields in a row. One one the right side and one on the left side. In best case the whole text of the right side is always shown and the text on the left side takes the rest of the space. If the right text is too long the left text should have a min width, so that at least some text with ellipses is shown. In my solution the right text takes the whole width and the left text is hidden. Even when I set the min width (I thought I set it). Any idea how to solve it?
    Row(
            horizontalArrangement = Arrangement.SpaceBetween
        ) {
            Text(
                modifier = Modifier
                    .weight(1f)
                    .widthIn(min = 200.dp),
                textAlign = TextAlign.Start,
                text = "Left side side side side side side side",
                maxLines = 1,
                overflow = TextOverflow.Ellipsis,
            )
            Text(
                textAlign = TextAlign.End,
                text = "Right right right right right right",
                maxLines = 1,
                overflow = TextOverflow.Ellipsis
            )
        }
    In best case I would be able to tell the right text to take only 60% but if the 60% is not required take less. With
    weight(0.6f)
    it's a fixed space of 60% even if it's not required
    f
    s
    8 replies · 3 participants
  • p

    Peng Wang

    05/23/2022, 7:19 AM
    the state is not a SnapshotState , why whenever it changed the canvas can redraw?
    val state = mutableListOf(0f)
    
    @Preview
    @Composable
    fun test() {
        Box {
            Button(onClick = {
                state[0] += 100f
            }) {
                Text(" > ")
            }
    
            Canvas(Modifier.fillMaxSize()) {
    
                drawCircle(color = Color.Red, center = Offset(state[0], 500f), radius = 200f)
            }
        }
    }
    a
    z
    2 replies · 3 participants
  • f

    fengdai

    05/23/2022, 7:51 AM
    Hey everyone, I’ve built a Compose library for ExoPlayer media playbacks: https://github.com/fengdai/compose-media Is anyone interested in this? Any feedback is appreciated! 😄 Here is the screenshot of the sample, which demonstrates how the library’s
    Media
    composable reacts to parameters changes:
    👍 6
    🙌 3
    t
    y
    +1
    7 replies · 4 participants
  • r

    RE

    05/23/2022, 9:14 AM
    Recently I checked the nowinandroid project to follow the best practices, but its repoistry layer doesn't seem to have any content about network requests. Both room/datastore support Kotlin Flow, and it will be automatically updated in Flow after data manipulation. But what about okhttp/retrofit? If the user action is handled in the viewmodel, how can I inform the api layer to re-initiate the network request and return the new data in the flow? are there any examples
    y
    f
    5 replies · 3 participants
  • s

    Sam Stone

    05/23/2022, 3:00 PM
    Can I store a lambda in a variable that generates a (possibly nested) view, and only invoke the lambda if a certain condition is met (i.e. only add the view to the hierarchy if a condition is met)?
    :yes: 1
    a
    1 reply · 2 participants
  • j

    Joseph Hawkes-Cates

    05/23/2022, 4:44 PM
    I am working on a Composable that is essentially this: https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/35122[…]3/original/pHTRjVez4mINgemCp15Ws5OFNs3a-xBXjw.jpg?1620046726. Anyone have thoughts on the best way to achieve something similar? See my thoughts in 🧵
    z
    13 replies · 2 participants
  • j

    Ji Sungbin

    05/23/2022, 4:49 PM
    Every Layout composable emits a ReusableComposeNode. But what does Reusable mean here? Below is the code of ReusableComposeNode.
    @Composable inline fun <T : Any, reified E : Applier<*>> ReusableComposeNode(
        noinline factory: () -> T,
        update: @DisallowComposableCalls Updater<T>.() -> Unit
    ) {
        if (currentComposer.applier !is E) invalidApplier()
        currentComposer.startReusableNode()
        if (currentComposer.inserting) {
            currentComposer.createNode { factory() }
        } else {
            currentComposer.useNode()
        }
        currentComposer.disableReusing()
        Updater<T>(currentComposer).update()
        currentComposer.enableReusing()
        currentComposer.endNode()
    }
    I noticed with this code that the only difference between ReusableComposeNode and ComposeNode is the way the groups are created. The KDoc of startReusableNode(), which is the group creation method used in ReusableComposeNode, is written as follows.
    Start a group that tracks a the code that will create or update a node
    that is generated as part of the tree implied by the composition. A
    reusable node can be reused in a reusable group even if the group key
    is changed.
    I don’t know what reused means here. Does this mean that the node is reused as measured? (normal nodes will start with the measure phase. but does the reused node skip the measured phase?)
    a
    a
    6 replies · 3 participants
  • p

    Peter Mandeljc

    05/23/2022, 5:39 PM
    What happens, when you don't use "key" in "LazyColumn"? Will the hash of the item be used instead?
    f
    j
    5 replies · 3 participants
  • m

    Marcin Wisniowski

    05/23/2022, 7:44 PM
    Is Compose only working on specific Kotlin versions? I cannot seem to update past Kotlin 1.6.10, because then Compose complains.
    j
    l
    +3
    14 replies · 6 participants
  • m

    Marcin Wisniowski

    05/23/2022, 9:58 PM
    Long shot, but after updating (Compose Compiler
    1.1.0-beta03
    , Kotlin
    1.5.31
    ) to (Compose Compiler
    1.1.0-beta04
    , Kotlin
    1.6.0
    ) I am having a weird issue where after navigating back to a Fragment the Fragment's UI (View-based, not Compose) is no longer responsive. Single-activity app with navigation component, issue appears with any View-based Fragment after navigating back to it (fine on Compose Fragments). I am having a hard time debugging this, or seeing why would updating the Compose Compiler affect non-Compose Fragments, did anyone see a similar issue?
    b
    a
    19 replies · 3 participants
  • m

    Mini

    05/24/2022, 7:35 AM
    A while back “Common tests” was moved from Backlog to “in focus” in the compose roadmap, are there any news on the progress on this? Its a pretty hard topic to search for 😅
    a
    a
    2 replies · 3 participants
  • c

    Colton Idle

    05/24/2022, 8:03 AM
    Anyone familiar with MapView + AndroidView. I just have a simple map, and I hit a network call to get the lat + long of 5 places. When the network call returns I add those 5 items to a
    var list = mutableStateListOf<Location>()
    but my map never updates until I reload that page. I believe I'm doing everything correclty, because if I comment out my MapView code and replace it with a Column + forEach then all of my items show when the network call completes. Is there some sort of thing you need to hook into with AndroidView + mapView to have it respond to mutableState?
    a
    y
    8 replies · 3 participants
  • a

    alaershov

    05/24/2022, 8:43 AM
    Hello Composers! Is there any straightforward way to directly handle software keyboard input without using
    TextField
    ? Or more specifically: what is the most reasonable way to create a PIN code input widget with input from software keyboard? I'm used to hacks with invisible
    EditTexts
    in View system, but I'd like very much to avoid this stuff in Compose and do it the right way. Any recommendations?
    c
    d
    7 replies · 3 participants
  • a

    Aaron Waller

    05/24/2022, 9:05 AM
    Anyone else has a worse performance using Grid Layouts in compose compared to the old View System? I know the common solution is to use R8 and using the release build apk. I mean yes it is much better but not as good as the old view System. Especially when you use 4-5 Columns.
    n
    f
    3 replies · 3 participants
  • j

    Joseph Hawkes-Cates

    05/24/2022, 2:17 PM
    Is there a way to have some content (in my case a Text) in a column exceed the width of the column?
    f
    2 replies · 2 participants
Powered by Linen
Title
j

Joseph Hawkes-Cates

05/24/2022, 2:17 PM
Is there a way to have some content (in my case a Text) in a column exceed the width of the column?
f

Filip Wiesner

05/24/2022, 2:20 PM
You can use
wrapContentWidth
modifier to ignore the Columns width constraints
Allow the content to measure at its desired width without regard for the incoming measurement minimum width constraint, and, if unbounded is true, also without regard for the incoming measurement maximum width constraint.
🙌 1
:plus1: 1
j

Joseph Hawkes-Cates

05/24/2022, 2:20 PM
ahh, nice. Thanks!
👍 1
View count: 7