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

    Zach Klippenstein (he/him) [MOD]

    05/21/2020, 9:48 PM
    What’s the best way to block input and focus to a Composable? I don’t want it to draw with the disabled emphasis, just make it not interactive.
    • 1
    • 1
  • m

    molikto

    05/22/2020, 2:43 AM
    On snapshot after the change to move to function-body-based code generation strategy, my project now triggers some compiler exception (getParent is null). Is there a way to debug where it is triggered?
    l
    • 2
    • 6
  • m

    manueldidonna

    05/22/2020, 12:02 PM
    I'm having some trouble on limiting the number of chars of a TextFieldValue.
    var selection by state { TextRange(0, 0) }
    var text by state { repository.getText() }
    TextField(
        value = TextFieldValue(text, selection),
        onValueChange = { 
            selection = it.selection
            // there is a a limit on the number of chars. 
            // The passed text is automatically truncated
            text = repository.updateText(it.text) 
        }
    )
    When I exceed the number of chars, I have some problems with the keyboard that continues to record the inputs, so I have to press the delete button more times than needed.
    l
    v
    • 3
    • 2
  • s

    Socheat KHAUV

    05/22/2020, 2:59 PM
    ContextAmbient.current is not available, is there alternative way to get current Context ?
    l
    k
    v
    • 4
    • 7
  • k

    Klaas Kabini

    05/23/2020, 3:30 AM
    @Mihai Popa As I was checking as list of commits you guys made on compose branch. I saw a commit that says updating compose to 0.1.0-dev14 but has not seen the one that says updating compose to 0.1.0-dev13. Was this done intentional jumping from 0.1.0-dev12 straight to 0.1.0-dev14?
    j
    a
    • 3
    • 3
  • p

    pavi2410

    05/23/2020, 1:34 PM
    I don't know why it's not building. I just updated AS to canary 9. This was showing that the bundled Kotlin library is old, so I updated it to 1.3.72. Now, it says that it differs with the bundled version. Also, the Compose plugin is incompatible
    m
    a
    • 3
    • 3
  • p

    pardom

    05/23/2020, 2:40 PM
    What's the best way to add a header to an
    AdapterList
    ? Can it be nested in a
    VerticalScroller
    ?
    a
    • 2
    • 3
  • k

    Kazemihabib1996

    05/23/2020, 3:38 PM
    What's the equal of textView.setText(
    (Html.fromHtml(htmlString , Html.FROM_HTML_MODE_LEGACY)));
    in compose?
    a
    p
    • 3
    • 11
  • c

    camkadev

    05/23/2020, 5:47 PM
    also in
    dev11
    it’s impossible to extend
    Brush
    class with message
    '<init>': it is private in 'Brush'
    k
    • 2
    • 2
  • c

    carbaj0

    05/24/2020, 10:36 AM
    what is the better approach to applying a margin to a component (FilledTextField for example)?
    s
    • 2
    • 2
  • k

    Kazemihabib1996

    05/24/2020, 5:41 PM
    I can't understand the
    IntrinsicSize.Min and Max
    for example:
    @Composable
    fun SameWidthBoxes() {
        // Builds a layout containing three Box having the same width as the widest one.
        //
        // Here preferredWidth min intrinsic is adding a width premeasurement pass for the
        // Column, whose minimum intrinsic width will correspond to the preferred width of the largest
        // Box. Then preferredWidth min intrinsic will measure the Column with tight width, the
        // same as the premeasured minimum intrinsic width, which due to fillMaxWidth will force
        // the Box's to use the same width.
        Stack {
            Column(Modifier.preferredWidth(IntrinsicSize.Min).fillMaxHeight()) {
                Box(
                    modifier = Modifier.fillMaxWidth().preferredSize(20.dp, 10.dp),
                    backgroundColor = Color.Gray
                )
                Box(
                    modifier = Modifier.fillMaxWidth().preferredSize(30.dp, 10.dp),
                    backgroundColor = Color.Blue
                )
                Box(
                    modifier = Modifier.fillMaxWidth().preferredSize(10.dp, 10.dp),
                    backgroundColor = Color.Magenta
                )
            }
        }
    }
    In this example changin
    Min
    to
    Max
    makes no difference. I'm trying to understand the difference of them. but in the below one:
    @Composable
    fun SameWidthTextBoxes() {
        // Builds a layout containing three Text boxes having the same width as the widest one.
        //
        // Here preferredWidth max intrinsic is adding a width premeasurement pass for the Column,
        // whose maximum intrinsic width will correspond to the preferred width of the largest
        // Box. Then preferredWidth max intrinsic will measure the Column with tight width, the
        // same as the premeasured maximum intrinsic width, which due to fillMaxWidth modifiers will
        // force the Boxs to use the same width.
        Stack {
            Column(Modifier.preferredWidth(IntrinsicSize.Max).fillMaxHeight()) {
                Box(Modifier.fillMaxWidth(), backgroundColor = Color.Gray) {
                    Text("Short text")
                }
                Box(Modifier.fillMaxWidth(), backgroundColor = Color.Blue) {
                    Text("Extremely long text giving the width of its siblings")
                }
                Box(Modifier.fillMaxWidth(), backgroundColor = Color.Magenta) {
                    Text("Medium length text")
                }
            }
        }
    }
    it makes difference. I can't understand why in the
    SameWidthBoxes
    IntrinsicSize.Min
    means :
    minimum intrinsic width will correspond to the preferred width of the largest Box
    why not the smallest Box. as it is in
    SameWidthTextBoxes
    sample.
    m
    • 2
    • 8
  • s

    Socheat KHAUV

    05/24/2020, 11:58 PM
    how to get screen width and screen height in a composable function?
    a
    l
    c
    • 4
    • 5
  • l

    Leland Richardson [G]

    05/25/2020, 2:29 PM
    Basically, Box will add the padding modifier for you, and it won't be the "left most" modifier in the chain, which means it can't be emulated exactly by applying the padding modifier yourself
    k
    • 2
    • 2
  • d

    Dean Djermanović

    05/25/2020, 6:06 PM
    Why
    onClick
    doesn't trigger when I add
    ripple
    modifier?
    Clickable(onClick = { ... }) {
            Icon(
                ...
                modifier = Modifier.ripple(false) + Modifier.padding(4.dp)
            )
        }
    When I remove
    Modifier.ripple(false)
    ,
    onClick
    triggers normally.
    m
    • 2
    • 1
  • c

    caelum19

    05/25/2020, 6:11 PM
    Box(
        modifier = Modifier
            .preferredSize(500.dp, 500.dp)
            .drawBackground(
                HorizontalGradient(
                    0.0f to Color.Red,
                    0.5f to Color.Green,
                    1.0f to Color.Blue,
                    startX = Px.Zero,
                    endX = 500.dp.toPx()
                )
            )
    )
    I'd like for a gradient's end to match the parent's width - is there a nicer way to do this?
    z
    k
    a
    • 4
    • 6
  • c

    camkadev

    05/25/2020, 6:22 PM
    Is there a way to get Parent size to use them to resize child elements ?
    z
    • 2
    • 2
  • r

    Ruairi McGuigan

    05/26/2020, 4:51 PM
    Hi, I am setting up Dagger in my Jetpack Compose project. However, receive this build error ->
    e: java.lang.NoSuchMethodError: org.jetbrains.kotlin.codegen.state.GenerationState$Builder.isIrBackend(Z)Lorg/jetbrains/kotlin/codegen/state/GenerationState$Builder;
    i
    • 2
    • 1
  • k

    kagomez

    05/27/2020, 12:30 AM
    Hi I was searching for a BottomSheet behavior on the material package of Compose but didn’t find it, is there a plan for releasing that component? I think that can be achieved by drawing a component untils is visible and having the “peek” property defined
    m
    • 2
    • 6
  • t

    Tristan

    05/27/2020, 1:38 AM
    Hello, In the Jetnews app, I saw we are using an AppContainer which contains the variables we will share across the app (such as repositories). We have to pass down this object to each component. What prevent us from using ambient?
    ☝️ 2
    m
    a
    c
    • 4
    • 6
  • l

    Lilly

    05/27/2020, 4:44 PM
    Are there any best practices for requesting permissions in compose. While the request has to remain in activity the dialog will be displayed in composable functions...feels a bit fragmented. Maybe there is solution I'm not aware of!?
    a
    c
    +2
    • 5
    • 8
  • p

    pavi2410

    05/27/2020, 6:58 PM
    Can the corners be smooth in preview?
    z
    r
    • 3
    • 7
  • d

    doodla

    05/27/2020, 7:14 PM
    I can’t find
    AndroidView
    in Compose. Is that a separate package? https://developer.android.com/reference/kotlin/androidx/ui/viewinterop/package-summary?hl=hi-in
    k
    r
    • 3
    • 3
  • k

    Kazemihabib1996

    05/27/2020, 7:19 PM
    Applying
    relativePaddingFrom
    after
    preferredSize
    centers the children is that a bug? it works correctly when applied before
    preferredSize
    Box(
                gravity = ContentGravity.BottomStart,
                modifier = Modifier
                    .drawBackground(Color.Green)
                    .preferredSize(200.dp)
                    .relativePaddingFrom(FirstBaseline, after = 30.dp)
    
            ) {
                Text(
                    text = "Example of after relativePaddingFrom"
                )
            }
    z
    m
    • 3
    • 4
  • t

    tcracknell

    05/27/2020, 8:23 PM
    Hello! The latest Jetpack Compose minor release, dev12, has just been released! You can get it now on Google’s Maven Repository. Release notes are available at https://developer.android.com/jetpack/androidx/releases/compose and https://developer.android.com/jetpack/androidx/releases/ui. As always, feedback is welcome; please log issues at https://issuetracker.google.com/issues/new?component=612128!
    👏 20
    ❤️ 4
    🎉 8
    :kotlin-flag: 3
    k
    • 2
    • 1
  • m

    Mark Murphy

    05/27/2020, 9:39 PM
    In
    dev11
    , you could call a top-level composable function from a library via reflection by passing in
    currentComposer
    :
    val clazz = Class.forName("com.commonsware.jetc.specimen.basics.ActionCheckboxKt")
    val demoMethod = clazz.methods.find { it.name == "ActionCheckboxDemo" }
    
    demoMethod?.let {
        it.isAccessible = true
        it.invoke(null, currentComposer)
    }
    In this case,
    ActionCheckboxDemo()
    has zero parameters in terms of the way the source is written. But, if you looked at the compiled class file (e.g., via External Libraries in Studio), you would see that the function was rewritten to take a
    Composer
    . I'm uncertain how to accomplish this in
    dev12
    . If I look at the compiled class file, it claims to take zero parameters. If I try
    invoke()
    , it claims to take 3 parameters. The release notes support the three-parameter signature, though the docs seem to be somewhat mangled:
    A Composable function accepting a single parameter is transformed into a function accepting 3 parameters, the additional parameters are the Composer, a ‘key’ integer. a bitmask integer used to propagate metadata through calls.
    If I change the invocation to
    it.invoke(null, currentComposer, 0, 0)
    , it runs. But... should I be deriving better values for those integers from somewhere?
    l
    • 2
    • 11
  • r

    romainguy

    05/27/2020, 9:46 PM
    I’m trying very hard not to ask why you’re using reflection 😁
    ➕ 2
    m
    • 2
    • 1
  • h

    henrikhorbovyi

    05/27/2020, 9:56 PM
    Hello everyone, I know it's simple. but how can I change activity with compose? Specifically inside a click block of a ListItem.
    j
    c
    • 3
    • 3
  • z

    Zach Klippenstein (he/him) [MOD]

    05/28/2020, 3:31 AM
    For the new
    StateFlow<T>.collectAsFlow()
    extension introduced in dev12 (https://android-review.googlesource.com/c/platform/frameworks/support/+/1308154), why does
    T
    have a non-null upper bound? `StateFlow`’s
    T
    is nullable, and I don’t see why this bound should be required for the extension.
    l
    j
    a
    • 4
    • 13
  • a

    allan.conda

    05/28/2020, 6:08 AM
    Hi, I’m new here and in learning compose. 👋 I’m trying to append to a list outside the
    @Composable
    function using
    LiveData#observeAsState
    . and modify the list-order internally for rendering (drag-reorder ux), but I can’t get it to work; I guess I lack understanding about
    MutableState
    . Any ideas? The new list doesn’t update the state 😞
    • 1
    • 1
  • h

    henrikhorbovyi

    05/28/2020, 6:30 AM
    Hello everyone I'm trying to show an image but the
    imageResource()
    always return
    null
    . What am I missing? I'm using version
    dev12
    a
    • 2
    • 2
Powered by Linen
Title
h

henrikhorbovyi

05/28/2020, 6:30 AM
Hello everyone I'm trying to show an image but the
imageResource()
always return
null
. What am I missing? I'm using version
dev12
a

allan.conda

05/28/2020, 6:31 AM
if it’s a vector image, you have to use vectorResource. Had the same issue 😄
h

henrikhorbovyi

05/28/2020, 1:16 PM
Perfect! 😄 It worked... thank you mate
💚 1
View count: 3