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

    loloof64

    02/02/2021, 10:39 AM
    Hi ! I'm trying to build a simple grid with a border as a custom component. But the result is still weird : https://ibb.co/nMh6Y3x
    SimpleGrid.kt
    • 1
    • 2
  • w

    why

    02/02/2021, 11:07 AM
    hi.. after compose alpha11 I can't use indication with clickable() I wanna set it to
    null
    like this:
    Modifier.clickable (indication = null){}
    any idea?
    m
    s
    z
    • 4
    • 7
  • m

    Michael Elgavi

    02/02/2021, 12:12 PM
    Does
    LazyColumn
    measure the entire list on first composition, and only composes the visible items? Or is the measurement also only done for the visible items?
    z
    • 2
    • 4
  • y

    Yuri Drigin

    02/02/2021, 1:23 PM
    Hi folks! has anyone catch this strange bug? compose version: ‘1.0.0-alpha10’. compose navigation: ‘1.0.0-alpha06’. When navigation disabled all compiled successful
    Untitled
    c
    • 2
    • 2
  • l

    loloof64

    02/02/2021, 2:18 PM
    Hi again. I'm trying to build a Canvas, but I don't know how. I've been looking at https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas, but Canvas is an interface, and I don't know if there is a class implementing it.
    j
    • 2
    • 13
  • n

    Neal Sanche

    02/02/2021, 4:30 PM
    I have a rather odd regression betweeen alpha07 and alpha11. I had followed some instructions on how to integrate with CameraView from CameraX using an AndroidView, and specifically I had implemented a preview use case, and had scaled the CameraView into a small thumbnail just as a view-finder for what the camera was looking at. This worked fine in alpha07, but in alpha11 it looks like the surface is being cropped instead of scaled as I was expecting. It'd take me a bit to make a minimal reproduction case, and will in the thread if required. Any ideas from the compose authors here on why a SurfaceView would be clipped now instead of scaled as before?
    👀 1
    a
    f
    +2
    • 5
    • 16
  • l

    lewis

    02/02/2021, 4:42 PM
    Hopefully something simple that I'm missing. I'm trying to change the display when a collection of paged items is empty. While this works when the UI is initially composed with no items, once items appear and disappear, the display remains empty.
    val lazyItems = posts.collectAsLazyPagingItems()
    
        if(lazyItems.itemCount == 0) {
            NoItemsLeft()
        } else {
            LazyColumn(modifier = modifier) {
                items(lazyItems) {
    j
    • 2
    • 3
  • g

    grandstaish

    02/02/2021, 7:27 PM
    is there a way to slow down animations in compose? (for debugging)
    s
    j
    +4
    • 7
    • 14
  • t

    Tash

    02/02/2021, 8:23 PM
    Hi all, had a question for Compose devs: were there any discussions/concerns around misuse of Ambients? For example, I read something that suggested Ambients be used almost as a replacement for scoped DI components (i.e. Dagger @Scoped Component). That idea feels like a misuse of Ambients, but I cant put my finger on why. Are there any guidelines/mindsets we should follow when dealing with Ambients?
    v
    k
    c
    • 4
    • 7
  • s

    spierce7

    02/02/2021, 11:06 PM
    I’m using an
    AndroidView
    composable to embed a native Android View into Jetpack Compose. However, I’d when a certain event happens on my model, I’d like to re-create the
    AndroidView
    , removing the old, and replacing it with a newly created one. How would I go about doing that?
    j
    a
    • 3
    • 4
  • a

    Alexa_Gal

    02/03/2021, 2:09 AM
    does anyone know if it’s possible to show two different views in a
    ModalBottomSheetLayout
    ? at the moment i only get the next view after the second click/compose
    doble tap.mov
    s
    k
    • 3
    • 3
  • y

    Yuri Drigin

    02/03/2021, 7:19 AM
    Can somebody help me with
    Theme
    ? I create colors, palettes and theme like in the sample, but colors changed only for text not for backgrounds (surfaces)
    Untitled
    s
    • 2
    • 3
  • a

    André Thiele

    02/03/2021, 9:25 AM
    Can someone help with AS not auto-refreshing my compose previews?
    p
    • 2
    • 1
  • k

    Kshitij Patil

    02/03/2021, 9:47 AM
    I want to group two related components that are part of ConstraintLayout to a separate
    @Composable
    function. Currently I was planning to borrow the constraints from parent layout through
    Modifier
    type parameter.
    @Composable
    fun CustomGroup(
        <required-fields>,
        ...,
        firstComponentModifier: Modifier = Modifier,
        secondComponentModifier: Modifier = Modifier,
        ...,
        <other optional fields>
    ) { ... }
    This seems to be working for me but the linter gives this error warning: “Modifier parameter should be named modifier”. I think my use-case is valid and we shouldn’t restrict modifier name to be modifier only or we should make
    ConstrainedLayoutReferences
    class public so that I could pass it on as parameter to other function
    a
    c
    +2
    • 5
    • 5
  • j

    Jorkoh

    02/03/2021, 12:53 PM
    Hey, I'm getting started with animations on Compose by playing with the bottom bar implementation on the Jetsnack sample. Why
    indicatorIndex
    here doesn't use
    animateFloatAsState()
    ? Is there a difference?
    +  val indicatorIndex by animateFloatAsState(selectedIndex.toFloat(), animSpec)
    
    -  val indicatorIndex = remember { Animatable(0f) }
    -  val targetIndicatorIndex = selectedIndex.toFloat()
    -  LaunchedEffect(targetIndicatorIndex) {
    -      indicatorIndex.animateTo(targetIndicatorIndex, animSpec)
    -  }
    d
    • 2
    • 1
  • l

    loloof64

    02/03/2021, 1:49 PM
    Hi ! I've looked at the dragGestureFilter documentation (https://developer.android.com/reference/kotlin/androidx/compose/ui/gesture/package-summary#draggesturefilter), but it is defined for a Modifier. So, I can't use it for a canvas element (such as drawCircle) : is there an equivalent for setting a drag on a canvas element ?
    a
    • 2
    • 2
  • p

    Piotr Prus

    02/03/2021, 3:17 PM
    Hi community. I am trying to make a search view in top app bar with suggestions listed below the topbar in floating region. I manage to do the change from title and icon to editText for user input. Now, i would like to display some suggestions. I tried dropdownmenu, but I cannot display it with fill width. The maximum width set on this composable item is something around 3/4 of screen width. It's there any way to make such a list in column below the topbar or i should build the custom layout with custom appBar?
    👀 1
    u
    • 2
    • 2
  • c

    Colton Idle

    02/03/2021, 3:24 PM
    Is there any guide on how to define colors for my app if we're not following Material theme?
    y
    f
    • 3
    • 3
  • n

    Noé Casas

    02/03/2021, 4:36 PM
    It is possible to have something like the
    .clickable
    modifier but with information of the position where the user clicked?
    b
    l
    • 3
    • 3
  • k

    Kirill Grouchnikov

    02/03/2021, 6:42 PM
    Kotlin 1.4.30 is out...
    :party-parrot: 6
    s
    j
    +2
    • 5
    • 9
  • m

    Michael Elgavi

    02/03/2021, 9:25 PM
    Is it possible to animate a composable from normal sized (wrap content) to
    fillMaxHeight()
    ? I guess it would be possible with
    ConstraintLayout
    , wondering if there's a simpler solution.
    a
    • 2
    • 1
  • c

    Colton Idle

    02/03/2021, 10:49 PM
    My company isn't using material, so we're just defining colors like this
    object MyCompanyColors {
        val Background = Color(0xFFFFFFFF)
        val Text = Color(0xFF424242)
        //20 other colors
    }
    Anyone see anything wrong with this? I feel like the docs and codelabs don't really have any guidance on how to create a Color sheet UNLESS you go the material theme route
    j
    c
    • 3
    • 2
  • i

    izyaboi

    02/04/2021, 8:03 AM
    one question i want to implement audio exoplayer in my project . is it right that i must interop the views that used in exoplayer?https://developer.android.com/jetpack/compose/interop have anyone a example for exoplayer with compose? or is there a compose project for it?
    c
    • 2
    • 1
  • a

    allan.conda

    02/04/2021, 8:27 AM
    Is Compose following UpperCamelCase convention for naming constants? https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]in/androidx/compose/material/Swipeable.kt?q=SwipeableDefaults
    :yes: 2
    j
    • 2
    • 1
  • a

    allan.conda

    02/04/2021, 9:33 AM
    Are there considerations for exposing internal components/functions for building material components like
    Switch
    so we can build our own design components with less effort? Just like we have
    BasicTextField
    , I’m wondering if we could have something like
    BasicSwitch
    . Currently we resort to copy-pasting non-public components in order to easily build our own design. I’m wondering if this is the ideal way to move forward for such cases.
    j
    • 2
    • 2
  • j

    julioromano

    02/04/2021, 10:15 AM
    Can you type in a compose text field using the PC’s keyboard when running the app in an emulator? It’s not working on my machine, I have to use the on-screen keyboard inside the emulator.
    a
    t
    s
    • 4
    • 7
  • j

    julioromano

    02/04/2021, 2:40 PM
    Is there anything like `RecyclerView`’s
    StateRestorationPolicy.PREVENT_WHEN_EMPTY
    for
    LazyColumn
    ?
    LazyColumn
    doesn’t currently restore the scroll position if the list’s data is fed using something like
    val myList by aFlow.collectAsState(emptyList())
    . For example during configuration changes (like rotation, dark/light theme switch, etc.) the flow will be resubscribed to and so
    aFlow
    will temporarily emit
    emptyList()
    causing the saved scroll position to be discarded. This is a workaround I found but I was hoping it could be handled better:
    if (myList.isNotEmpty()) {
        LazyColumn() {
           // .....
        }
    }
    i
    a
    a
    • 4
    • 6
  • d

    David Attias

    02/04/2021, 2:58 PM
    Hey guys, I'm having trouble to use
    popUpTo
    with a route which includes an optional argument. Is it supposed to work? Is it an issue ?
    i
    d
    • 3
    • 7
  • k

    Kensuke Sano

    02/04/2021, 3:22 PM
    Is there any way to specify width as a percentage?
    Box(modifier = Modifier.width(100.dp)) {
               Box(modifier = Modifier.preferredSize(50 %) ) { // 50% equals 50.dp
                        Text("HELLO")
               }
    }
    a
    • 2
    • 2
  • c

    Colton Idle

    02/04/2021, 5:45 PM
    When I set buttonColors on a button, I get this error
    Functions which invoke @Composable functions must be marked with the @Composable annotation
    colors = object : ButtonColors {
        override fun backgroundColor(enabled: Boolean): Color =
            JetsnackTheme.colors.color1
    
        override fun contentColor(enabled: Boolean): Color =
            JetsnackTheme.colors.color1
    }
    if I remove that block, then everything compiles fine. Any ideas?
    c
    j
    • 3
    • 13
Powered by Linen
Title
c

Colton Idle

02/04/2021, 5:45 PM
When I set buttonColors on a button, I get this error
Functions which invoke @Composable functions must be marked with the @Composable annotation
colors = object : ButtonColors {
    override fun backgroundColor(enabled: Boolean): Color =
        JetsnackTheme.colors.color1

    override fun contentColor(enabled: Boolean): Color =
        JetsnackTheme.colors.color1
}
if I remove that block, then everything compiles fine. Any ideas?
c

Cyril Find

02/04/2021, 5:51 PM
you should annotate both functions with
@Composable
c

Colton Idle

02/04/2021, 6:15 PM
@Cyril Find
Conflicting overloads: @Composable public open fun backgroundColor
=(
c

Cyril Find

02/04/2021, 6:17 PM
are you updating to alpha11 ?
c

Colton Idle

02/04/2021, 6:18 PM
Still on alpha10 due to reasons
c

Cyril Find

02/04/2021, 6:18 PM
oh ok nevermind
did you try extracting the object as a named class ?
c

Colton Idle

02/04/2021, 7:13 PM
I did not. I'm going to try to convince my team to move to alpha11 and then see if it keeps happening. might take a few days though.
Thanks @Cyril Find
👍 1
c

Cyril Find

02/04/2021, 10:47 PM
Untitled
⬆️ by the way in alpha11 the implementation changes a bit, maybe you have some versions incompatibilities ? it looks like this now for me
j

Jan Bína

02/05/2021, 12:11 AM
I guess that the easiest way is to use one of the functions from
ButtonDefaults
object, like this:
OutlinedButton(
    colors = ButtonDefaults.buttonColors(
        backgroundColor = Color.Black
        ...
    )
)
😮 1
:thank-you: 1
👍 1
c

Colton Idle

02/05/2021, 2:22 PM
@Jan Bína thanks. I was unaware of this. Gotta look into ButtonDefault some more to see why i would use that over the other possible solution.
@Jan Bína that worked! Thank you!
👍 1
View count: 1