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

    Gabriel Feo

    05/06/2020, 11:19 PM
    Is
    Box
    the recommended way of creating simple shapes such as this BottomSheet handle?
    m
    • 2
    • 1
  • v

    Val Salamakha

    05/07/2020, 1:21 AM
    Does kotlin build-1.4-M2-eap-70 support compose 0.1.0-dev10?
    l
    • 2
    • 1
  • s

    SrSouza

    05/07/2020, 3:48 AM
    Hi folks, there is anyway to load a Compose FontFamily from a set of files in the device that was downloaded ?
    a
    • 2
    • 2
  • d

    dagomni

    05/07/2020, 2:26 PM
    Am I doing something wrong or onSelected in BottomNavigationItem is not working? 🤔
    BottomNavigationItem(
        modifier = Modifier.fillMaxWidth()
                + Modifier.ripple(enabled = false),
        alwaysShowLabels = true,
        icon = { Icon(vectorResource(item.first)) },
        text = { Text(stringResource(item.second)) } },
        selected = selectedItem == item,
        onSelected = {
            println("println statement that is not getting called")
        }
    )
    l
    • 2
    • 4
  • c

    clhols

    05/07/2020, 4:31 PM
    I am trying to use observeAsState on a LiveData, but I am getting:
    Type 'State<List<MuNowNext>>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
    I don't get that error message. I see State has this extension:
    State<T>.getValue(thisObj: Any?, property: KProperty<*>)
    An Nothing? is not Any?, so why does it want a Nothing? ? Code is:
    @Composable
    fun ChannelsList(channels: LiveData<List<MuNowNext>>) {
        val channelsList by channels.observeAsState(initial = emptyList())
    a
    • 2
    • 2
  • m

    manueldidonna

    05/08/2020, 2:32 AM
    There is a way to detect a swipe gesture?
    l
    g
    m
    • 4
    • 4
  • v

    Val Salamakha

    05/08/2020, 3:52 AM
    This is shown in plugins
    l
    • 2
    • 3
  • v

    Val Salamakha

    05/08/2020, 4:17 AM
    I use the following version
    l
    • 2
    • 2
  • m

    manueldidonna

    05/08/2020, 8:54 AM
    I've created a composable that has an higher zIndex than the other composables in the Box, so it's always visible but it doesn't receives click events. Is it a bug or my mistake?
    Box {
        // here doesn't reiceive clicks, but it's visible because it has an higher zindex
        HomeToolbar(title = currentBox.name, modifier = Modifier.preferredHeight(56.dp))
        VerticalScroller {
            Column {
                Spacer(modifier = Modifier.preferredHeight(56.dp))
                PokemonList(pokemon = pokemonPreviews.value) { slot ->
                    state.selectedPokemonIndex = slot
                }
                Spacer(modifier = Modifier.preferredHeight(16.dp))
            }
        }
        // here it's both visible and reiceives clicks
        HomeToolbar(title = currentBox.name, modifier = Modifier.preferredHeight(56.dp))
    }
    a
    • 2
    • 3
  • d

    dagomni

    05/08/2020, 11:07 AM
    This code is put inside Box
    val state = viewModel.currentState.collectAsState(viewModel.getInitialState())
    
    Column(Modifier.fillMaxSize() + Modifier.drawBackground(color = Color.Blue)){
        AdapterList(modifier = Modifier.fillMaxSize(), data = state.value.dataList) {
            Text(
                modifier = Modifier.fillMaxWidth() + Modifier.preferredHeight(80.dp),
                text = it.title,
                color = Color.White
            )
        }
    }
    and gives me a runtime error while executing
    LayoutNode@6292b16 children: 1 measureBlocks: MeasuringIntrinsicsMeasureBlocks@a9f8420{ measureBlock=androidx.ui.foundation.BoxKt$Box$1$1@0ed31d9 } is not measured, draw requested
    When I remove AdapterList, it runs just fine EDIT: it's not working when data parameter is an empty list
    a
    • 2
    • 4
  • a

    aiidziis

    05/08/2020, 11:49 AM
    When using
    FilledTextField
    in emulator, it is not possible to move cursor with arrow keys (<- & ->). Is this a known issue?
    l
    z
    • 3
    • 6
  • g

    grandstaish

    05/08/2020, 7:02 PM
    In case anyone else is having compilation issues, adding
    '-XXLanguage:+NewInference'
    does not work with google’s custom compiler
    1.3.70-dev-withExperimentalGoogleExtensions-20200424
    l
    • 2
    • 2
  • s

    Stefan Sturm

    05/09/2020, 9:36 AM
    What do you think? When will compose be ready for production?
    m
    • 2
    • 1
  • m

    manueldidonna

    05/09/2020, 12:23 PM
    After a fling, any kind of scrollable layout (vertical/horizontal scroller & adapterlist) needs 2 clicks. The layout interprets the first click as the end of a fling and the second click as clicking on the list item. Is this a bug?
    20-05-09-14-07-03.mp4
    r
    • 2
    • 3
  • m

    manueldidonna

    05/09/2020, 3:06 PM
    I have 2 questions about the TextField composable. How can I make the text cursor blink? How can I select the text? With a native EditText widget I can do it with a double tap/long press gesture on the text
    s
    • 2
    • 4
  • r

    rkeazor

    05/09/2020, 3:09 PM
    hey will constraint layout and motion layout be ported to compose?
    :yes: 1
    f
    • 2
    • 5
  • c

    codeslubber

    05/10/2020, 4:56 AM
    Created a new project tonight after updating to latest of everything (requisite half hour of looking at console updates that look like circa 1960) and it doesn’t run (asked for empty Compose Activity). The template still references
    dev03
    and it still has that stuff in it where kotlin version is a string in the base gradle file and you have to change that according to the app build file but then it is unhappy back in the other file. Seriously build is such a grease fire, it’s never going to be better. Probably one of the reasons Rust is gaining so much popularity… anyway time left for compose? 0
    k
    k
    +2
    • 5
    • 20
  • c

    carlos cdmp

    05/10/2020, 3:55 PM
    Hello, there is any way to create custom views with compose, so I can for example use them as a viewHolder view, I have the Composable fun but usually y just use inflate of the xml
    f
    • 2
    • 2
  • c

    carlos cdmp

    05/10/2020, 5:11 PM
    And someone can tell me why this simple thing
    Row {
        Text("Sample Text")
        Button("Click")
    }
    Is throwing IllegalStateException: No colors found!?
    a
    • 2
    • 2
  • p

    passiondroid

    05/10/2020, 5:59 PM
    How to set the background color of Container ? Need help
    a
    • 2
    • 1
  • a

    amar_1995

    05/10/2020, 7:10 PM
    DataTable
    in compose is removed. Is there any alternative for that ?
    a
    v
    • 3
    • 5
  • k

    kagomez

    05/11/2020, 7:22 PM
    Hi guys, is using Modifier object to something like,
    Button(onClick = { state.counter++ }, modifier = Modifier.tag("testTag"))
    but on my UiTests the method findByTag is not recognizing the button, any insights on this?
    a
    m
    • 3
    • 7
  • l

    Lilly

    05/11/2020, 9:17 PM
    Hi does someone know how to use TextField with inputType of
    Password
    ? This is showing the text still plain:
    TextField(
        value = textState,
        modifier = Modifier.fillMaxWidth(),
        onValueChange = onChange,
        keyboardType = KeyboardType.Password
    )
    a
    v
    • 3
    • 2
  • l

    Lilly

    05/11/2020, 9:26 PM
    I guess this is version dev10?
    z
    • 2
    • 2
  • m

    MBegemot

    05/12/2020, 12:01 PM
    This is one of my two screens, when first launched , as statusApp.lang has just been initialized the getListHeadlines is called, if I change the statusApp.fontSize, the headlines are redrawn but the headlines are not loaded which is what I want, but If I go to the next screen which is a detail screen, when I came back by pressing the back button and assigning the application screen to be again the headlines screen, I've got the elements reloaded as if stattusApp.lang would have changed.
    a
    • 2
    • 5
  • k

    Kazemihabib1996

    05/12/2020, 3:26 PM
    In dev10 there is a problem with Box background color and
    size
    modifiers: backgroundColor not works in below code:
    Box(backgroundColor = Color.Blue, modifier = Modifier.width(200.dp).height(100.dp))
    works in below one:
    Box(backgroundColor = Color.Blue, modifier = Modifier.size(200.dp))
    m
    • 2
    • 4
  • v

    vanpra

    05/12/2020, 4:47 PM
    I'm trying to write a music player style composable but I'm a bit stuck on how you would go about implementing the swipe motion where the current element on the screen is swiped off to the left while a new item appears from the right. Any ideas?
    m
    • 2
    • 1
  • z

    Zach Klippenstein (he/him) [MOD]

    05/13/2020, 2:56 AM
    Is it possible to take a
    CompositionReference
    from a composable function, pass it through to a
    FrameLayout
    hosted inside the composition, and have that legacy view pass that reference through to a composable hosted inside itself? I.e. so that any ambients in effect where the legacy view is added to the composition get propagated to the leaf composable inside the legacy view. I’m doing the naïve thing right now of just having the legacy view call
    setViewContent
    instead of
    setContent
    , which takes a
    CompositionReference
    . However, the leaf composable doesn’t seem to be getting model updates, and throws an `IllegalStateException`: “Unsupported node type LayoutNode” if I try composing something like a
    Text
    . I’m sure all this infrastructure is full of holes right now, but is this something that’s ideally supposed to work?
    setViewContent
    has a TODO on it to remove, and the only other API that seems relevant here is
    subcomposeInto
    but that requires a
    ComponentNode
    which I haven’t tried to figure out how to get yet.
    a
    l
    • 3
    • 28
  • r

    R Brian Amesbury

    05/13/2020, 4:44 AM
    this is the error from the build: https://github.com/moonlitdoor/mld-amessage-android/runs/669546358#step:5:830
    a
    • 2
    • 2
  • k

    Kazemihabib1996

    05/13/2020, 2:26 PM
    When should we use
    staticAmbientOf
    instead of
    ambientOf
    ? what's the benefit of using
    staticAmbientOf
    that
    RippleTheme
    for example uses that instead of
    ambientOf
    ?
    a
    c
    • 3
    • 5
Powered by Linen
Title
k

Kazemihabib1996

05/13/2020, 2:26 PM
When should we use
staticAmbientOf
instead of
ambientOf
? what's the benefit of using
staticAmbientOf
that
RippleTheme
for example uses that instead of
ambientOf
?
a

Adam Powell

05/13/2020, 2:37 PM
staticAmbientOf
has lower overhead but if it ever changes in place, we will invalidate and recompose the entire subhierarchy below the
Providers
where it changed, since we don't track precise location of reads for static ambients.
In effect, "dynamic" ambients are just a static ambient that holds a
State<T>
that holds the "real" value of the ambient
so in the case of dynamic ambients, that
State<T>
instance from the
Providers
in the composition stays constant and never changes, only the observable value changes when you provide a new value for the ambient key.
k

Kazemihabib1996

05/13/2020, 2:47 PM
@Adam Powell Thank you So you used
staticAmbientOf
for
RippleTheme
as in most applications developers set that one time and won't change it later?
c

Chuck Jazdzewski [G]

05/13/2020, 4:39 PM
That is correct. Use
staticAmbientOf
for ambients that are unlikely to ever change or if they do change they likely invalidate the entire tree anyway. Here, change is defined as changing the value provided at the point it is provided. If a static ambient is re-provided, it is not counted as being changed and will not invalidate the tree below it, the tree below just sees a different value than the tree above.
👍 1
View count: 1