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

    alorma

    10/27/2020, 7:07 AM
    use
    AmbientEmphasisLevels
    👍 1
    p
    • 2
    • 1
  • g

    Grigorii Yurkov

    10/27/2020, 7:22 AM
    How am I supposed to preview composable function which invokes
    viewModel()
    function?
    m
    j
    • 3
    • 6
  • m

    Mayank Saini

    10/27/2020, 8:36 AM
    This is my implementation for
    Marquee
    . Is this correct?
    @Composable
    fun MarqueeText(announcement: String, marqueeSpeed: MarqueeSpeed, modifier: Modifier = Modifier) {
        val scrollState = rememberScrollState()
        val scope = remember { CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate) }
        onDispose { scope.cancel() }
        ScrollableRow(scrollState = scrollState, modifier = modifier, children = {
            Row {
                repeat(1000) {
                    Text(
                        text = announcement, maxLines = 1
                    )
                }
            }
            val scrollBy = when (marqueeSpeed) {
                MarqueeSpeed.SLOW -> 2f
                MarqueeSpeed.MEDIUM -> 6f
                MarqueeSpeed.FAST -> 9f
            }
            scrollState.smoothScrollBy(scrollBy)
            scope.launch {
                while (true) {
                    scrollState.smoothScrollBy(scrollBy)
                    delay(50)
                }
            }
    
        })
    }
    👆 1
    z
    • 2
    • 16
  • k

    Kshitij Patil

    10/27/2020, 8:46 AM
    How to use legacy xml layouts in compose? seems like
    AndroidView(resId)
    has been removed in the snapshot build. Should I use
    LayoutInflator
    inside viewblock?
    • 1
    • 1
  • a

    Adriano Celentano

    10/27/2020, 8:51 AM
    https://twitter.com/SophosAdriano/status/1320853215068495872?s=19
    👏 4
    i
    • 2
    • 3
  • m

    Marko Gajić

    10/27/2020, 11:48 AM
    Does Compose support Fragment Transitions with common Views? e.g. ImageView transitioning from LazyItem list to detail screen header, etc?
    i
    • 2
    • 3
  • g

    Grigoriev Dmitriy

    10/27/2020, 12:16 PM
    Guys, I have a questions about colors. I created a splash screen composable which is a constraintlayout with two Text() inside. Color of both of text components is setted to yellow. But when I get this screen on my app, both of them are blue. If I add backgroundColor to ConstraintLayout() it becomes also light blue. Anybody knows what is the problem? Maybe I need to add somewhere Surface()?
    a
    g
    m
    • 4
    • 21
  • m

    Maik

    10/27/2020, 1:23 PM
    Is there any obvious reason why the modifier
    drawOpacity
    enables clipping in addition to the alpha value. From my point of view this seems to be a mistake, because it is not 100% clear from the modifier name or its description.
    /**
     * Draw content with modified opacity (alpha) that may be less than 1.
     *
     * Example usage:
     * @sample androidx.compose.ui.samples.OpacitySample
     *
     * @param opacity the fraction of children's alpha value.
     */
    @Stable
    fun Modifier.drawOpacity(
        @FloatRange(from = 0.0, to = 1.0) opacity: Float
    ) = drawLayer(alpha = opacity, clip = true)
    j
    a
    n
    • 4
    • 3
  • a

    alorma

    10/27/2020, 3:04 PM
    Hi, has
    AppBarIcon
    been removed?
    l
    • 2
    • 3
  • s

    spierce7

    10/27/2020, 3:35 PM
    Has anyone measured the compilation time of compose? I’m curious because I know compose uses a different version of the Kotlin compiler or something or other. I’m not exactly sure how it works, so I’m curious if there are any problems with it in terms of scaling compose in large projects.
    z
    g
    • 3
    • 16
  • a

    alorma

    10/27/2020, 3:36 PM
    What I'm doing wrong?
    s
    g
    c
    • 4
    • 7
  • b

    Bruce Xia

    10/27/2020, 3:59 PM
    Does anyone know a good article/demo of focus management using Compose? I'm adding Compose into my existing tv app and I'm not able to move focus to my buttons using tv control
    a
    r
    • 3
    • 7
  • a

    alorma

    10/27/2020, 5:11 PM
    Hi! One question... What's the best way to have a list of themes? SO we can create a theme switcher
    j
    a
    • 3
    • 7
  • k

    karandeep singh

    10/27/2020, 5:58 PM
    is there any compose counterpart of customlayout manager of recyclerview?
    a
    • 2
    • 4
  • i

    iamthevoid

    10/27/2020, 7:11 PM
    is there native way to calculate and apply diff to lazy column items like DiffUtils for recycler view?
    j
    • 2
    • 5
  • z

    zoha131

    10/27/2020, 7:25 PM
    has anyone built OTP Composable?
    a
    a
    • 3
    • 3
  • g

    Grigorii Yurkov

    10/27/2020, 7:47 PM
    How to center text vertically?
    Text(
                    text = money,
                    modifier = Modifier
                            .weight(.3f)
                            .wrapContentWidth(Alignment.End)
                            .wrapContentHeight(Alignment.CenterVertically),
                    fontSize = 12.sp
            )
    a
    s
    +3
    • 6
    • 69
  • g

    Guy Bieber

    10/27/2020, 7:50 PM
    On a Samsung phone (SM-G960U1) I get a white line on the bottom of the screen with a grey pull-up bar. This does not happen on other android phones. Any way to overcome this in compose?
    z
    m
    • 3
    • 19
  • l

    louiscad

    10/27/2020, 10:16 PM
    It seems that since 1.0.0-alpha05,
    Text
    is no longer selectable by default. How can we make it selectable again?
    s
    z
    • 3
    • 21
  • j

    Javier

    10/27/2020, 10:45 PM
    Why it is taking so long to fix the getValue/setValue auto import 🤔 ?
    z
    a
    • 3
    • 2
  • t

    Tim Malseed

    10/28/2020, 1:08 AM
    I'm just getting started with compose.. I want to interop with Flow.. But this doesn't render a list:
    • 1
    • 3
  • c

    Cash Hsiao

    10/28/2020, 3:57 AM
    I have a weird problem with upgrading to alpha05. The elements inside
    ConstraintLayout
    will have a probability to be rendered or not. I also discovered this issue in Owl project.
    c
    • 2
    • 3
  • k

    Kshitij Patil

    10/28/2020, 5:21 AM
    Has anyone used Hilt with Compose? I'm willing to inject different instances of same type based on some condition. Also, is it possible to inject dependencies directly into a composable? I think 'Ambient' is another way of maintaining dependencies.
    j
    • 2
    • 2
  • c

    Chethan

    10/28/2020, 5:36 AM
    Hi Guys, Do we have dropdown spinner in Android Compose, I want to make Textfield with dropdown spinner to select the item in the country list . what are the options to make this ?
    a
    • 2
    • 11
  • i

    Irving

    10/28/2020, 6:27 AM
    Hello, How could I find the sample provided in the source code through the
    @sample
    tag: just like:
    @sample androidx.compose.animation.core.samples.KeyframesBuilderForPosition
    .I did't find it in the github. Could anyone give me a link?Tanks a lot!
    h
    • 2
    • 2
  • g

    Grigorii Yurkov

    10/28/2020, 9:40 AM
    Is there hotkey to turn this
    ButtonText(text = "Text", onClick = {}, modifier = Modifier.padding(top = 16.dp))
    into this
    ButtonText(
          text = "Text",
          onClick = {},
          modifier = Modifier.padding(top = 16.dp)
    )
    I am so tired to do this manually.
    g
    a
    • 3
    • 4
  • m

    Mayank Saini

    10/28/2020, 10:43 AM
    Hey, What should I use to show
    horizontal progress
    in compose. Should I use
    slider
    ?
    🤘 1
    c
    • 2
    • 1
  • k

    Kshitij Patil

    10/28/2020, 11:04 AM
    Has
    navigation-compose
    alpha released? Where can I track the new releases?
    🇳🇴 2
    c
    i
    • 3
    • 3
  • a

    allan.conda

    10/28/2020, 11:18 AM
    Scrolling lists via LazyColumnFor should have been significantly improved from alpha05. These lists are still slow in our projects however. Were anyone else able to notice significant improvements or the current state is still quite slow in your opinion? I’d like to hear your thoughts. Also hoping that the API still has a lot of points of performance improvement that can be theoretically worked on (I understand it’s currently an experimental API).
    👍 1
    b
    s
    • 3
    • 4
  • a

    allan.conda

    10/28/2020, 11:38 AM
    Is it possible to make the Composable not clip within its bounds when using AnimatedVisibility? slideInVertically() seems unusable due to the clipping
    d
    • 2
    • 10
Powered by Linen
Title
a

allan.conda

10/28/2020, 11:38 AM
Is it possible to make the Composable not clip within its bounds when using AnimatedVisibility? slideInVertically() seems unusable due to the clipping
d

Doris Liu

10/29/2020, 12:54 AM
slideInVertically
shouldn't clip, but its parent may choose to clip it. Which composable are you seeing the clipping in?
a

allan.conda

10/29/2020, 12:54 AM
ah. I’m trying to animate my LazyColumn items
d

Doris Liu

10/29/2020, 12:58 AM
That sounds like a reasonable use case. Please file a bug if there's no good way to do it through public API. 🙂
a

allan.conda

10/29/2020, 1:21 AM
Thanks! I’m going to see what I can find and do that if I can’t otherwise.
Do you know how I can make AnimatedVisibility only run once on LazyColumn(For) ? It seems to work fine for ScrollableColumn, but for LazyLoading it gets animated when the composable appears again in view.
Ok I guess I can file it as a bug and it can either be considered or set to won’t fix
d

Doris Liu

10/29/2020, 1:25 AM
In LazyColumn(For) you'll need to hoist the state for whether the item has been shown. If an item has been shown, you can set the
initiallyVisible
param to true, to prevent animations from firing.
a

allan.conda

10/29/2020, 1:59 PM
I’ve been trying to do that but I’m encountering problems. It recomposes instantly in my case and doesn’t animate. I can’t find API to listen to the end of the animation. If it isn’t too much to ask could you provide a minimal sample of what you mean?
d

Doris Liu

10/29/2020, 7:50 PM
Without knowing the details of your use case, my advice is around preventing items from animating when added to the tree again:
val items = remember { colors.map {
    Pair(it, mutableStateOf(false) /*initiallyVisible*/) } }
LazyColumnFor(
    items
) {
    AnimatedVisibility(true, initiallyVisible = it.second.value) {
        onDispose {
            it.second.value = true
        }
        // Children here
    }
}
a

allan.conda

10/30/2020, 9:38 AM
Thank you! That works
View count: 4