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

    adjpd

    09/05/2021, 10:46 PM
    If I want a different text size for different screen sizes, I'm going to be using the styles XML system, right? Or is there a jetpack compose way?
    • 1
    • 1
  • r

    Rick Regan

    09/06/2021, 1:39 AM
    I'm using Accompanist
    systemUiController.setSystemBarsColor()
    to set dark icons. When I switch between apps using gesture navigation there is a lag in my test app where the system icons are momentarily white before changing back to black. Is there a way to avoid this? (Video and code in thread.)
    ➕ 1
    l
    a
    • 3
    • 6
  • e

    eygraber

    09/06/2021, 4:13 AM
    If I have an interfacez:
    interface Renderer {
      fun render()
    }
    
    interface ComposeRenderer : Renderer {
       @Composable override fun render()
     }
    will the compose mechanics work correctly if I call
    render
    polymorphically?
    class MyActivity : AppCompatActivity {
      private val renderer: Renderer = object : ComposableRenderer ...
      override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent { renderer.render() }
      }
    }
    a
    h
    z
    • 4
    • 11
  • t

    theapache64

    09/06/2021, 8:07 AM
    🔴 📺 Can I use Compose in an android-tv project? I guess there was a lack of DPAD support earlier. How can I track the status? 🙂
    g
    • 2
    • 8
  • t

    Tomáš Hubálek

    09/06/2021, 8:29 AM
    Hello, I have a question regarding architecture of multiplatform project. I understand that it is quite easy to share view models. UI and other platform specific components can be mapped using `expected`/`actual`. Did anybody try to use such a approach for building iOS app? Is that technically even possible? What prevents from creating iOS app in JetPack Compose? For me JetPack Compose seems like great multiplatform development framework but there is a very little info on using it on iOS.
    f
    h
    +3
    • 6
    • 8
  • s

    Semyon Zadorozhnyi

    09/06/2021, 10:07 AM
    Hi guys. We currently migrating from views to compose and recently encountered a strange performance issue We have viewpager2 with two fragments. We decided to migrate one of the fragments to compose by setting ComposeView to it. Each fragment takes the whole screen. The old screen is loading fine but as soon as you trigger creation of the second fragment (with compose view). Screen hangs for ~600ms All consequent switches are working fine (under 16ms) Details inside
    a
    a
    z
    • 4
    • 7
  • t

    theapache64

    09/06/2021, 11:39 AM
    ✅ [RESOLVED] Build error: Getting
    e: androidx.compose.compiler.plugins.kotlin.IncompatibleComposeRuntimeVersionException: You are using an outdated version of Compose Runtime that is not compatible with the version of the Compose Compiler plugin you have installed. The compose compiler plugin you are using (version 1.0.2) expects a minimum runtime version of 1.0.0.
    Details in 🧵
    s
    • 2
    • 5
  • f

    Fredrik Larsen

    09/06/2021, 1:04 PM
    As far as I can see it's currently not possible to have LazyColumn containing another LazyColumn. Is there a known way to get the following behavior in compose: • Vertical list of lazy loaded "modules" (supports paging) • Module is either horizontal or vertical (also lazy loading) I can currently make a lazy vertical list of modules if all of the modules are horizontal, but not if they are vertical. Using RecyclerView I can do this if I accept that the vertical modules will bind all items when bound. Would love some input on this! 🙂
    n
    j
    a
    • 4
    • 17
  • p

    Peter Mandeljc

    09/06/2021, 2:21 PM
    um, is it possible for
    Column
    to have
    Arrangment.spacedBy()
    and
    Arrangment.Center
    at the same time?
    n
    • 2
    • 2
  • r

    Rafiul Islam

    09/06/2021, 2:35 PM
    I am using a keyboard software in which long pressing V key paste the selected text. It is working fine in other non-compose edittext. But it isn't working in my compose TextField. Am I missing something?
    • 1
    • 1
  • r

    Rob

    09/06/2021, 2:43 PM
    When using LazyColumn/Column on ChromeOS, mouse wheel and mouse drag doesn't scroll. Only touch inputs seem to work with scrolling. Is there a way to fix this?
    a
    s
    • 3
    • 2
  • m

    myanmarking

    09/06/2021, 4:09 PM
    is there any flag like legacy views ‘inEditMode’ so we can render different things on preview (for example, coil url image) ?
    a
    z
    • 3
    • 12
  • d

    dector

    09/06/2021, 4:54 PM
    Hi. Do we have standard way to achieve gradient on the right without scaling square linear gradient? (color of the points on the diagonal should be the same)
    ➕ 5
    c
    n
    c
    • 4
    • 10
  • a

    Akram Bensalem

    09/06/2021, 6:34 PM
    Hello, How to put LazyGrid inside scrollable Column ?
    v
    • 2
    • 3
  • b

    bitkiller

    09/06/2021, 6:46 PM
    Is it good or bad practice having the child composable providing an element to parent? E.g. a content providing an action to be placed in the toolbar. The intention is to avoid hoisting state from child and allow the reuse of the parent.
    z
    • 2
    • 1
  • а

    Антон X

    09/06/2021, 6:47 PM
    Hey guys. Is it possible to convert Spannable to compose Text style?
    z
    • 2
    • 3
  • a

    Akram Bensalem

    09/06/2021, 6:57 PM
    I want to add LazyRow, LazyColumn & LazyVerticalGrid inside vertically scrollable column. But when i add LazyVerticalGrid it causes error.
    java.lang.IllegalStateException: Nesting scrollable in the same direction layouts like ScrollableContainer and LazyColumn is not allowed. If you want to add a header before the list of items please take a look on LazyColumn component which has a DSL api which allows to first add a header via item() function and then the list of items via items().
    Any help ?
    f
    j
    +3
    • 6
    • 18
  • j

    Justin Yue

    09/06/2021, 9:34 PM
    I have
    mutableStateListOf()
    object, which I named days, that holds
    data class Cell(val text: String, var isSelected: Boolean).
    When I want to change the isSelected status, I have to reassign one element to a new Cell with the updated boolean. I would prefer to just reassign one element's isSelected boolean, but that doesn't seem to work. Does anybody know why?
    c
    z
    • 3
    • 7
  • l

    Libor Bicanovsky

    09/06/2021, 10:39 PM
    Assuming the loading spinner is based on some external api call
    n
    k
    • 3
    • 2
  • v

    VuLong

    09/07/2021, 2:41 AM
    Hello, How i can fullscreen editing view for soft keyboard input in landscape use jetpack compose? Sorry for my bad english.
    c
    • 2
    • 1
  • z

    Zoltan Demant

    09/07/2021, 4:16 AM
    Is it possible to synchronize the
    LazyListState
    (scroll position) between multiple
    LazyRow
    ? Ive tried using one
    rememberLazyListState
    but that results in weird scrolling glitches; Im sort of assuming that Ill need to collect all scroll events and update each
    LazyListState
    ?
    c
    • 2
    • 5
  • p

    Paulo Martins

    09/07/2021, 9:26 AM
    Hey! I am trying to update an
    AndroidView
    based on my
    CustomViewModel
    changes.
    @Composable
    fun FilamentViewer(viewModel: CustomViewModel) {
        var modelViewer by remember { mutableStateOf<ModelViewer?>(null) }
    
        launchInComposition {
            while (true) {
                withFrameNanos { frameTimeNanos ->
                    modelViewer?.render(frameTimeNanos)
                }
            }
        }
    
        AndroidView({ context ->
            LayoutInflater.from(context).inflate(
                R.layout.filament_host, FrameLayout(context), false
            ).apply {
                val (engine) = scenes[product.material]!!
                modelViewer = ModelViewer(engine, this as SurfaceView).also {
                    setupModelViewer(it)
                }
            }
        })
    }
    how can I make it change dynamically? I need to update the modelViewer.scene entity
    z
    а
    • 3
    • 12
  • a

    Anastasia Rozovskaya

    09/07/2021, 10:29 AM
    Hello! Is it possible to add 2-3 gifs on top of each other in jetpack compose?
    t
    f
    +2
    • 5
    • 7
  • j

    Jan Skrasek

    09/07/2021, 10:44 AM
    After upgrade to 1.0.2 (from 1.0.0) it seems that my Local stopped working (seems like the value is not changed in the child sub-tree)
    public enum class ContentEmphasis { Normal, Minor, Subtle, Disabled }
    public val LocalContentEmphasis: ProvidableCompositionLocal<ContentEmphasis> = compositionLocalOf { ContentEmphasis.Normal }
    then using it like this
    fun Foo(label: @Composable () -> Unit) {
        CompositionLocalProvider(LocalContentEmphasis provides ContentEmphasis.Minor) {
            label()
        }
    }
    seems that components in label doesn't have the value changed. Did something changed? Or is my code wrong in some way?
    l
    • 2
    • 9
  • c

    Ch8n

    09/07/2021, 12:25 PM
    Hi everyone, can we customize text field like this one or have to create compounded compose view?
    a
    n
    +2
    • 5
    • 9
  • v

    vitaliy

    09/07/2021, 2:04 PM
    Hi everybody, I’m working on a control with a ripple of this shape. It is kind of clipped on top and bottom
    rememberRipple(bounded = false)
    . So far it is simply rectangular as a
    Box
    with:
    modifier = Modifier
                .clickable(
                    interactionSource = remember { MutableInteractionSource() },
                    indication = rememberRipple(color = highlightColor),
                    enabled = enabled,
                    role = Role.Button,
                    onClick = onClick
                )
                .padding( <some paddings> )
    I’m running out of ideas and my Compose kung-fu is pretty basic so far. I’ll appreciate any hints you may have for me!
    k
    t
    • 3
    • 8
  • a

    adjpd

    09/07/2021, 5:07 PM
    I have custom
    Layout
    within a
    Column
    with
    fillMaxSize()
    . The
    Layout
    has two children. I want the second child to tell me its own intrinsic size. Currently I'm doing
    measurable.measure(constraints.copy(minWidth = 60, minHeight = 60))
    . But
    60
    is arbitrary. How can I ask the child to tell me its intrinsic size? (The child is an
    Icon
    within a
    Surface
    )
    z
    • 2
    • 6
  • v

    vgonda

    09/07/2021, 9:34 PM
    Resurfacing this topic. I know Compose 1.1.0-alpha03 depends on Kotlin 1.5.30. Any ideas on when support will be in a stable release?
    c
    • 2
    • 1
  • l

    Lauren Yew

    09/07/2021, 9:42 PM
    Has anyone tried setting focus on the
    TopAppBar
    ? I'm trying to make it auto focus on the
    title
    rather than the
    navigationIcon
    , but none of the focus methods are working. I've tried setting
    focusOrder
    ,
    focusRequester
    , using
    DisposableEffect
    to requestFocus. Nothing is working. Talkback always wants to focus first on the navigation icon of the back button. I have a design request to focus on the title THEN the back button.
    n
    • 2
    • 9
  • b

    Brad Harris

    09/07/2021, 10:45 PM
    @cb I saw you made a custom swipe to refresh in the accompanist library. But I like how YouTube on iOS works. How hard would this be to implement. While looking at your source code as a reference. There are some differences though like the list slides down as the indicator slides down.
    Image from iOS.MP4
    l
    c
    c
    • 4
    • 10
Powered by Linen
Title
b

Brad Harris

09/07/2021, 10:45 PM
@cb I saw you made a custom swipe to refresh in the accompanist library. But I like how YouTube on iOS works. How hard would this be to implement. While looking at your source code as a reference. There are some differences though like the list slides down as the indicator slides down.
Image from iOS.MP4
l

Luis

09/07/2021, 11:57 PM
I know that on iOS, scrolling has a spring animation attached to it, so you can overscroll. Detecting that overscroll is as easy has checking the scroll offset.
On Android, you will probably need to fake the overscroll by adding some space, and then adjusting the scroll to always stick to after the Space. Then you would also need a spring animation that would scroll with the same resistance has it does on iOS, so it doesn’t feel like a normal scroll it feels like you are pulling something
Thats why you don’t usually see the same pull to refresh on Android, out of the box we don’t have those sweet spring animations that iOS has
b

Brad Harris

09/08/2021, 12:00 AM
Yeah :/ it’s complicated to get working perfectly
c

Chris Sinco [G]

09/08/2021, 3:02 AM
out of the box we don’t have those sweet spring animations that iOS has
Out of the box in iOS == baked into a List control and/or container that has scrolling?
l

Luis

09/08/2021, 4:54 AM
Yep, a UIScrollView uses a spring animation to deal with the overscroll
c

Chris Sinco [G]

09/08/2021, 5:52 AM
Gotcha. The Android 12 overscroll effect and the current glow effect are coming soon. But the springy effects are not in there since that’s not the design. But perhaps it’s worth exploring with Compose to animate things more in the platform
That is to say the baseline motion design will always be the look and feel of the platform first for overscroll in Compose Android. To have it behave more like iOS is not something we’d do out of the box. And even if we could make it possible to override I don’t think that’s desirable from the ecosystem POV where scrolling looks different across apps.
c

cb

09/08/2021, 6:34 AM
It should be fairly easy to overscroll the list. You could apply
Modifier.offset(swipeRefreshState.indicatorOffset)
to the list, which should work
:jetpack-compose: 4
🤯 2
+1 to Chris’ points though. Don’t look to YouTube for platform design guidance.
View count: 2