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

    Koneko Toujou

    09/10/2021, 10:41 PM
    Does Compose draw each Composable directly to screen or does it first composite each composable to a texture which ultimately ends up on screen Eg Row Text Would Compose first draw Row directly to screen, and then draw Text directly to screen Or would Compose first draw Text to a texture, and then draw Text's texture to Row's texture, and then draw Row's texture to screen
    z
    a
    r
    • 4
    • 13
  • m

    Mehmet Peker

    09/11/2021, 12:21 AM
    How can I detect that the application is in the background?Disposable Effect not working for me
    i
    • 2
    • 3
  • k

    Koneko Toujou

    09/11/2021, 2:35 AM
    Does Compose have a concept of padding like Android View System does
    c
    • 2
    • 8
  • k

    Koneko Toujou

    09/11/2021, 3:35 AM
    Where can I find the source code for how compose draws its contents to the screen? Specifically the stuff that deals with converting padding/spacing, relative locations and so on, into absolute placement positions for graphics api to render to within the region specified
    r
    • 2
    • 10
  • r

    Rafs

    09/11/2021, 10:17 AM
    How do I get my bottom sheet to cast a shadow? I only see the shadow if the
    sheetBackgroundColor
    and the
    backgroundColor
    of the
    BottomSheetScaffold
    are the same. I'm not sure if the shadow is there in the first image but I clearly cannot see it, it all looks flattened to me.
    w
    • 2
    • 1
  • s

    Sean Proctor

    09/11/2021, 12:12 PM
    I'm having some issues understanding how the layout work exactly. I have a LazyColumn that fills a part of the screen. If I wrap that in a SelectionContainer, it no longer fills the screen until there's enough content, and then it pushes the TextField off the screen. The following works as expected:
    Column(modifier = Modifier.fillMaxSize()) {
        LazyColumn(
            modifier = Modifier
                .fillMaxWidth()
                .weight(1f)
        ) {
            items(lines) { line ->
                Text(line)
            }
        }
        TextField(...)
    }
    If I put a SelectionContainer around the LazyColumn with the same modifier, it doesn't work as I expected. Anyone know why?
    🧵 1
    a
    • 2
    • 6
  • k

    Koneko Toujou

    09/11/2021, 3:01 PM
    Does the order of these modifiers matter?
    Modifier.padding
    Modifier.offset
    (or any other position modifier)
    Modifier.requiredHeight
    (or any other size modifier) For example
    Text(
        modifier = Modifier
            .padding(horizontal = 16.dp)
            .requiredHeight(50.dp)
            .offset(10.dp)
    )
    And
    Text(
        modifier = Modifier
            .requiredHeight(50.dp)
            .offset(10.dp)
            .padding(horizontal = 16.dp)
    )
    In which both have a height of 50 and offset of 10, and a padding of 16
    🧵 1
    :yes: 1
    a
    • 2
    • 11
  • k

    Koneko Toujou

    09/11/2021, 3:53 PM
    How is
    Modifier
    implemented such that
    this
    or
    it
    does not need to be passed to it or any of its methods? As the only way I can think of is as a command list builder or similar As
    Modifier
    seems to immediately be a very powerful tool to implement parameters and such with due to its simplicity and everything that can be modified is in a single class so it is easy to find a parameter of interest instead of having to search through lots of additional methods and such that might not be related to parameters at all
    c
    a
    +2
    • 5
    • 36
  • c

    Cicero

    09/11/2021, 3:54 PM
    Could someone share a good example of production level navigation with compose? I found this by accident and now I'm questioning some decisions. When I play my app I start with the splash screen, I verify the user state. and then decide where to go. I just learned that this might be incorrect. So shouldn't I use my splash screen to load new information? Should I have some sort of dynamic destination that does this information loading and lands you in whatever the "correct" destination might be?
    k
    • 2
    • 10
  • r

    rajesh

    09/11/2021, 4:42 PM
    I'm creating
    Button()
    and fill it with white color, but it gets filled with theme's primary color and not the white color.
    Button(
            modifier = Modifier
                .size(80.dp)
                .clip(CircleShape)
                .background(Color.White)
    //            .background(MaterialTheme.colors.surface) //It's also not working
                .border(5.dp, Color.White, CircleShape),
            onClick = {  })
        {
    
        }
    r
    • 2
    • 10
  • m

    Mjahangiry75

    09/11/2021, 4:43 PM
    why I can't find
    scaleIn()
    ?
    r
    • 2
    • 3
  • k

    Koneko Toujou

    09/12/2021, 5:08 AM
    How does Compose compute where to place each child? And which source file is responsible for this?
    z
    • 2
    • 2
  • s

    saket

    09/12/2021, 6:44 AM
    Has anyone noticed that
    SoftwareKeyboardController#show
    doesn’t work super reliably for their composable? I’m using it to auto-show the keyboard when a dialog is shown but I’m forced to use a small delay. I was wondering how are others showing keyboard?
    val keyboardController = LocalSoftwareKeyboardController.current
    val requester = remember { FocusRequester() }
    
    TextField(
      modifier = Modifier.focusRequester(requester),
      value = ...,
      onValueChange = ...
    )
    
    LaunchedEffect(Unit) {
      delay(50)
      focusRequester.requestFocus()
      keyboardController?.show()
    }
    z
    • 2
    • 2
  • f

    Florian

    09/12/2021, 7:35 AM
    Regarding lifecycle behavior etc., do I get the exact same result if I use
    collectAsState
    on a Flow vs
    observeAsState
    from LiveData?
    a
    a
    • 3
    • 4
  • f

    Florian

    09/12/2021, 10:41 AM
    It's good practice to declare an optional
    modifier
    parameter on my own composables and apply them to the outer-most composable in that function, right? Is the same also the case for my composable that just holds the entire screen content? it's not reusable and I don't need to pass any modifiers to it since it's handled internally.
    z
    • 2
    • 2
  • r

    Rafs

    09/12/2021, 1:14 PM
    Can I get better alternatives for detecting the scroll direction in a
    LazyColumn
    . Here is what I have but it looks too hacky to me even though it works really well. Code in thread....
    a
    d
    • 3
    • 4
  • a

    adjpd

    09/12/2021, 2:17 PM
    Like in Swift, can we somehow shorten
    Column(horizontalAlignment = Alignment.CenterHorizontally)
    to?
    Column(horizontalAlignment = .CenterHorizontally)
    to improve readability? It would be a, seemingly, simply thing but would increase the readbility to codebases massively.
    🇳🇴 2
    j
    z
    o
    • 4
    • 8
  • r

    Rob

    09/12/2021, 4:30 PM
    I think I found a bug in compose. This should display the text "blah" if I'm not mistaken.
    Untitled.kt
    a
    • 2
    • 11
  • a

    Archie

    09/12/2021, 5:05 PM
    Hi Guys, Just wondering whether anyone could explain the
    resistance
    in:
    Modifier.swipeable(
        state = swipeableState,
        anchors = anchors,
        reverseDirection = false,
        thresholds = { _, _ -> FractionalThreshold(0.0f) },
        resistance = resistanceConfig(anchors.keys, 0f, 0f), // This right here...
        orientation = Orientation.Vertical,
    )
    No matter what value I set it in, I can’t seem to see the difference in the Swipe behavior
    m
    • 2
    • 2
  • a

    Ayfri

    09/12/2021, 6:45 PM
    Hi, is there will be a iOS version of Compose soon ?
    🇳🇴 2
    f
    j
    +3
    • 6
    • 13
  • s

    Slackbot

    09/12/2021, 7:26 PM
    This message was deleted.
    a
    • 2
    • 1
  • r

    robercoding

    09/12/2021, 8:10 PM
    Hi, I'm using the
    modifier.draggable(...)
    to detect dragging from user. I want to know when user stops dragging, what's the best way to get this information? Is it possible with
    draggable(...)
    or there's other modifier that provides this exact information?
    r
    • 2
    • 5
  • r

    Rick Regan

    09/13/2021, 1:50 AM
    I'm looking at the JetNews sample app for its navigation structure and I see that it nests a
    Scaffold
    within a
    Scaffold
    . At the top level it has a Scaffold with a
    NavHost
    in the lambda, and each screen listed in the NavHost (
    composable
    ) has a Scaffold (no lambda). I think I see at least one reason why it does this -- to have a single NavHost at the top and to give each screen its own
    topBar
    -- but I wasn't expecting nested Scaffolds to be a thing (I had thought of it, obviously incorrectly, as a once-per-screen construct). In any case, I wanted to confirm that this is the best (only?) way to structure an app when using navigation.
    k
    • 2
    • 1
  • r

    ritesh

    09/13/2021, 8:16 AM
    Hi, Any one faced compose tooling being very slow while rendering in larger project? My build runs faster than compose preview and sometimes it takes forever to preview. I am on
    AS Artic fox 2020.3.1 Patch 2
    compose version -
    1.0.1
    👋 2
    n
    • 2
    • 1
  • t

    theapache64

    09/13/2021, 8:46 AM
    🧪 Compose Testing `createAndroidComposeRule`: Is it a good practice to create a separate activity to test composables that need android resources ? 🤔
    b
    • 2
    • 1
  • t

    theapache64

    09/13/2021, 10:49 AM
    🧪 Compose Testing: When to use
    assertIs[Not]Displayed
    and
    assert[DoesNot]Exists
    ? 🤔
    z
    • 2
    • 6
  • d

    dead.fish

    09/13/2021, 10:57 AM
    Sadly,
    AndroidComposeTestRule
    is not of much use for me, the implementation basically has two issues: 1. It doesn't work with Fragments, since
    setContent
    is directly called on the
    Activity
    of an
    ActivityScenario
    , ignoring fragment semantics completely. 2. It's impossible to test the UI with the viewmodel in integration, as one basically has to manually connect the `ViewModel`s state flow to a separate
    setContent
    call on the test rule, ignoring the beef of the viewmodel / view integration altogether. I wish the test architecure in compose would have been written around the fact to have an injectable
    Recomposer
    for testing purposes.
    • 1
    • 1
  • o

    Orhan Tozan

    09/13/2021, 12:24 PM
    Is there an (3rd-party) API for a horizontal list UI's, but instead of regular horizontal scrolling, it's like swiping/sliding, like a slideshow?
    b
    • 2
    • 2
  • l

    Lukasz Burcon

    09/13/2021, 12:44 PM
    Hey, I believe that the documentation for
    derivedStateOf
    is misleading, and it that SideEffect should be declared in
    remember
    using no keys to really benefit from its caching mechanism. Here’s a documentation using keys with remember with derivedStateOf:
    <https://developer.android.com/jetpack/compose/side-effects#derivedstateof>
    And here’s a documentation that doesn’t use keys in remembers:
    <https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#derivedStateOf(kotlin.Function0)>
    Any thoughts on that?
    z
    • 2
    • 7
  • o

    Orhan Tozan

    09/13/2021, 12:49 PM
    Is it possible for giving a fontSize in DP in Compose?
    f
    e
    a
    • 4
    • 10
Powered by Linen
Title
o

Orhan Tozan

09/13/2021, 12:49 PM
Is it possible for giving a fontSize in DP in Compose?
f

Filip Wiesner

09/13/2021, 12:51 PM
What are you trying to achieve? Making Text that does not scale with users scaling setting?
o

Orhan Tozan

09/13/2021, 12:51 PM
Yes
f

Filip Wiesner

09/13/2021, 12:53 PM
What is your usecase? 🤔
o

Orhan Tozan

09/13/2021, 12:54 PM
Just the requirements the app has of a card UI text not getting ugly because of user system settings
f

Filip Wiesner

09/13/2021, 12:56 PM
Just my personal opinions but I don't think that's good enough reason. You should make it work some other way that does not hurt users with bad sight.
o

Orhan Tozan

09/13/2021, 12:57 PM
Yeah that's the best UX solution
f

Filip Wiesner

09/13/2021, 1:09 PM
The solution should be to introduce your own
LocalDensity
with constant
fontScale
. But again, I highly doubt non-scaling text is good UX. I think it's just a bad compromise for "nice" UI. There is a reason why it's not a straightforward solution.
e

eygraber

09/13/2021, 2:26 PM
@Filip Wiesner I hear your argument a lot, but there are times where design calls for hero text. Absolutely nothing is gained by scaling it up, because it's already quite large. Whether design should call for hero text or not is a whole different discussion.
f

Filip Wiesner

09/13/2021, 2:34 PM
But is hero text still a hero text when everything is bigger? 🙂 I would argue that than it would lose it's importance. But yeah, every rule has an exception. That's why it's not impossible to do, only more complicated. And there might be better solution. The
LocalDensity
override was just the first thing that I thought of.
a

Albert Chang

09/13/2021, 3:28 PM
If you really want to do that,
fontSize = with(LocalDensity.current) { 20.dp.toSp() }
should be enough.
View count: 1