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

    Oussama Haff.

    10/14/2020, 7:26 AM
    Hello 👋 Is there a runtime layout inspector for Compose ? I’m using
    onRoot().printToLog()
    for tests, but I can’t find the equivalent for a running app.
    v
    • 2
    • 2
  • c

    Christian

    10/14/2020, 8:02 AM
    Hi everyone, does anybody knew how to set gravity or align text to
    end
    ? basically, cursor starts from the right using
    BaseTextField
    j
    s
    • 3
    • 10
  • d

    Denis Sakhapov

    10/14/2020, 8:07 AM
    Has anyone used 9patch images with compose? Can’t wrap my head around how to make it work. How can I set a 9patch as a background of, say, a
    Box
    ?
    🤘 1
    s
    n
    • 3
    • 4
  • p

    Philip Blandford

    10/14/2020, 9:46 AM
    What am I missing here? I want the red box to fill the space between the parent top and the top of the green box, but it ends up aligned to the centre of the green box.
    ConstraintLayout(Modifier.fillMaxSize()) {
      val (box1, box2) = createRefs()
      Box(Modifier.constrainAs(box1){
        top.linkTo(parent.top); bottom.linkTo(box2.top)
      }.background(Color.Red).fillMaxSize())
      Box(Modifier.constrainAs(box2){
       bottom.linkTo(parent.bottom); centerHorizontallyTo(parent)
      }.size(200.dp,50.dp).background(Color.Green))
    }
    z
    • 2
    • 4
  • h

    Hitanshu Dhawan

    10/14/2020, 12:42 PM
    Hey everyone, what’s the best way to have sizes in our theme? So that I can access it like
    MaterialTheme.sizes.medium
    And we can specify sizes like small, medium, large (similar to shapes).
    s
    z
    • 3
    • 3
  • r

    Rodri Represa

    10/14/2020, 1:46 PM
    Can I change the constrains of a component inside a
    ConstraintLayout
    in base of a
    mutableStateOf<Boolean>
    ? If the mutable value change, my component will have others constrains..
    z
    • 2
    • 4
  • a

    Adriano Celentano

    10/14/2020, 2:33 PM
    Following the Codelab about state / Step 6 / TodoItemInput https://developer.android.com/codelabs/jetpack-compose-state#5 As soon as i paste this code from the lab
    @Composable
    fun TodoItemInput(onItemComplete: (TodoItem) -> Unit) {
       // onItemComplete is an event will fire when an item is completed by the user
       Column {
           Row(Modifier
               .padding(horizontal = 16.dp)
               .padding(top = 16.dp)
           ) {
               TodoInputTextField(Modifier
                   .weight(1f)
                   .padding(end = 8.dp)
               )
               TodoEditButton(
                   onClick = { /* todo */ },
                   text = "Add",
                   modifier = Modifier.align(Alignment.CenterVertically)
               )
           }
       }
    }
    my app does not compile anymore
    w: ATTENTION!
    This build uses unsafe internal compiler arguments:
    
    -XXLanguage:+NonParenthesizedAnnotationsOnFunctionalTypes
    
    This mode is not recommended for production use,
    as no stability/compatibility guarantees are given on
    compiler or generated code. Use it at your own risk!
    
    e: warnings found and -Werror specified
    w: /Users/adrian/Workspace/Android/android-compose-codelabs-main/StateCodelab/start/src/main/java/com/codelabs/state/todo/TodoScreen.kt: (84, 19): Parameter 'onItemComplete' is never used
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':start:compileDebugKotlin'.
    > Compilation error. See log for more details
    s
    n
    s
    • 4
    • 8
  • t

    tcracknell

    10/14/2020, 5:12 PM
    Hello! The latest Jetpack Compose minor release, alpha05, is here! You can get it now on Google’s Maven Repository. Release notes are available at https://developer.android.com/jetpack/androidx/versions/all-channel. As always, feedback is welcome; please log issues at https://issuetracker.google.com/issues/new?component=612128.
    🤘 5
    🎉 58
    🐿 4
    🙏🏽 5
    a
    z
    +6
    • 9
    • 11
  • g

    Gavin

    10/14/2020, 10:56 PM
    I have a question surrounding the
    TextField
    and related components. I couldn't find a way to filter between an onFocus/blur event vs actual typing/keyboard actions. The
    onValueChange
    handler is firing when I click in and out of the TextField and causes some un-wanted side effects. Am I missing something or is there currently a way (or a way around) to only account for keyboard actions and ignore focus/blur actions?
    r
    • 2
    • 6
  • c

    Chethan

    10/15/2020, 3:46 AM
    How can I have getQuantityString for plurals in Compose ?
    n
    • 2
    • 2
  • m

    Manuel Vivo

    10/15/2020, 9:49 AM
    All samples and codelabs have been migrated already to 
    alpha05
     😄 Happy Composing! For the lazy: https://goo.gle/compose-samples https://goo.gle/compose-pathway
    👌 6
    🎉 23
    👍 7
    o
    c
    • 3
    • 4
  • d

    darkmoon_uk

    10/15/2020, 10:11 AM
    What's the deal with Compose components having this purple background? Did they purposely make the default theme obnoxious so you define your own? Is it too much to ask that they just look like the regular material design...
    🤨 1
    🤦‍♂️ 1
    s
    n
    c
    • 4
    • 6
  • c

    Ciprian Grigor

    10/15/2020, 3:25 PM
    I wonder how does compose UI toolkit works internally? Does it have something similar to Flutter RenderObject tree, heavy UI objects which are reused?
    👍 1
    z
    j
    b
    • 4
    • 7
  • v

    Vinay Gaba

    10/15/2020, 3:49 PM
    So in the latest release,
    launchInComposition
    got renamed to
    LaunchedTask
    . Eerily close to
    AsyncTask
    in name and functionally (not entirely true) 😆
    z
    a
    s
    • 4
    • 7
  • a

    Apoorv Patel

    10/15/2020, 4:40 PM
    Hi, I am trying to use 
    ConstraintLayout
      but i am not able to get the constraints to work properly.
    ConstraintLayout(modifier = Modifier.padding(top = 16.dp, bottom = 16.dp)) {
            val (profileImage, progressText1) = createRefs()
    
            Image(
                    modifier = Modifier
                            .constrainAs(profileImage){
                                start.linkTo(parent.start, 16.dp)
                            }.preferredWidth(72.dp)
                            .preferredHeight(72.dp)
                            .background(Color.Green),
                    asset = imageResource(R.drawable.unknown_profile_empty)
            )
    
            val half = createGuidelineFromTop(0.5f)
    
            Text(text = "Sample text", modifier = Modifier.background(Color.Red).constrainAs(progressText1) {
                bottom.linkTo(half, 0.dp)
                start.linkTo(profileImage.end, 0.dp)
                end.linkTo(parent.end, 16.dp)
            })
        }
    I am expecting that the text will align itself to the image end but it is not aligned to that
    h
    a
    • 3
    • 6
  • a

    allan.conda

    10/15/2020, 5:15 PM
    Column(
        Modifier.wrapContentHeight().aspectRatio(1f)
    ) {
        Icon(asset, Modifier.size(24.dp))
        Text("Action")
    }
    We expected this to be a square component; Why is Column expanding to the size of its parent? We figured to just use a fixed size to simplify things, I’m just curious why this wasn’t working. And I’m looking to know a solution for this in case we really need more dynamic sizing.
    g
    z
    • 3
    • 5
  • d

    Devesh Sanghvi

    10/15/2020, 11:27 PM
    How do we display strikethrough and bold text in Text component? I tried SpannableString and Html tags string but it does not seem to work.
    s
    n
    +2
    • 5
    • 13
  • f

    Fabio

    10/15/2020, 11:29 PM
    I'm aware of going stable next year, but is there a roadmap to help me decide when to start using it in prod before that?
    p
    • 2
    • 1
  • f

    Fabio

    10/16/2020, 2:25 AM
    What are your thoughts on using compose in prod? 💚 I'm already using 💙 it's ready for prod, planning to do so soon 🧡 planning for this year ❤️ planning for beginning of next year vote with reactions (I added 1 vote for each to make it easier)
    💜 1
    🤔 1
    💚 11
    💙 4
    ❤️ 28
    🧡 13
    z
    s
    +6
    • 9
    • 21
  • m

    Mahdi

    10/16/2020, 2:53 AM
    Hi. I'm using liveData in compose and use
    observeAsState
    It is very odd that after update liveData compose ui update is not happening, but on some events ( click on items) I can see that model is updated! Is it better way to have handle items state outside compose? Thanks
    z
    i
    • 3
    • 18
  • a

    allan.conda

    10/16/2020, 2:57 AM
    Trying to annotate with data classes with
    @Immutable
    and read this bit:
    data
     classes that only contain 
    val
     properties that do not have custom getters can safely be marked as Immutable if the types of properties are either primitive types or also Immutable:
    And then looked at compose-samples
    @Immutable
    data class Episode(
        @PrimaryKey @ColumnInfo(name = "uri") val uri: String,
        @ColumnInfo(name = "podcast_uri") val podcastUri: String,
        @ColumnInfo(name = "title") val title: String,
        @ColumnInfo(name = "subtitle") val subtitle: String? = null,
        @ColumnInfo(name = "summary") val summary: String? = null,
        @ColumnInfo(name = "author") val author: String? = null,
        @ColumnInfo(name = "published") val published: OffsetDateTime,
        @ColumnInfo(name = "duration") val duration: Duration? = null
    )
    I have data classes with
    Date
    . Anyway it should still be safe to annotate as long as I’m sure it doesn’t get changed right? Also, I have states with single-time events:
    data class Event<out T>(val content: T) {
        var consumed: Boolean = false
            private set
    
        fun consume(): T? =
            if (consumed) {
                null
            } else {
                consumed = true
                content
            }
    }
    I guess I can’t use `@Immutable`for such state classes…
    • 1
    • 1
  • p

    popalay

    10/16/2020, 5:25 AM
    I've just implemented Tetris using Jetpack Compose. Check it out! https://t.co/198aK53XLB https://twitter.com/devpopalay/status/1316789701508911105?s=19
    👍 1
    ❤️ 3
    🔥 32
    🤘 4
    💪 5
    🎉 10
    v
    • 2
    • 1
  • f

    fabio.carballo

    10/16/2020, 8:29 AM
    what is the best practice regarding the
    Component
    to use to just represent the
    background
    ? I understand the in MaterialTheme the
    Surface
    has a similar goal, but it takes by default the
    surfaceColor
    . In my case where I want the same practical use but so that the background color is always
    backgroundColor
    . From looking at usages, it seems only
    Scaffold
    actually uses this color, but internally still uses a
    Surface
    and changes the background color.
    ➕ 2
    n
    • 2
    • 2
  • j

    Javier

    10/16/2020, 9:20 AM
    @Ian Lake is there any more PR related with Navigation Args missing or the next snapshot will have Nav Args available?
    i
    • 2
    • 4
  • m

    Mikael Alfredsson

    10/16/2020, 1:05 PM
    I wanted to create a selfcontained “show version” component, simplest case would be like this
    @Composable
        fun versionText(){
            val versionName = packageManager.getPackageInfo(packageName, 0).versionName
            Text(text = versionName)
        }
    either this is the completely wrong way to do something like this, or I need some way to know if this composable is currently running in a preview, since the preview engine will not really show anything here (I think it even crashes silently somewhere)
    s
    • 2
    • 4
  • a

    alexandrepiveteau

    10/16/2020, 1:20 PM
    Hi ! Is there a way to apply a
    LinearGradient
    to a
    Text()
    composable ? I’ve looked a bit into the docs, but can only find usages of solid colors for text.
    s
    • 2
    • 1
  • i

    Ian Lake

    10/16/2020, 3:18 PM
    PSA for snapshot users: the main AndroidX build and the Compose build have recently been merged. This means that the
    /ui/
    part of your snapshot build URL should be removed and the URL should be in the format:
    maven { url '<https://androidx.dev/snapshots/builds/[buildId]/artifacts/repository>' }
    • 1
    • 2
  • i

    Ian Lake

    10/16/2020, 3:23 PM
    PSA for Navigation snapshot users: the Compose Navigation artifact group+name has been changed. It is now
    androidx.navigation:navigation-compose:1.0.0-SNAPSHOT
    (using build IDs of 6910220 or higher - make sure to switch to the new snapshot URL format ^). Working towards the first alpha 🙂
    🎉 10
    👏 6
    👍 8
    ✔️ 14
    b
    j
    j
    • 4
    • 11
  • b

    bryansills

    10/16/2020, 4:02 PM
    speaking of navigation, should something like this work?
    @Composable
    fun BasicNav() {
        var isLoggedIn by remember { mutableStateOf(false) }
        NavHost(startDestination = "Profile") {
            composable("Profile") { Profile(isLoggedIn) { isLoggedIn = !isLoggedIn } }
            composable("Dashboard") { Dashboard() }
            if (isLoggedIn) {
                composable("Scrollable") { Scrollable() }
            }
        }
    }
    (the lambda passed into
    Profile()
    ) is just connected to a
    Button
    to toggle the logged in state
    i
    • 2
    • 5
  • d

    dmnk_89

    10/16/2020, 4:30 PM
    hi! Is there a simple way to make a
    OutlinedTextField
    non editable? So that it like gray and doesn't show keyboard when focused.
    s
    z
    • 3
    • 3
Powered by Linen
Title
d

dmnk_89

10/16/2020, 4:30 PM
hi! Is there a simple way to make a
OutlinedTextField
non editable? So that it like gray and doesn't show keyboard when focused.
s

Siyamed

10/16/2020, 4:39 PM
Afaik there is not a way. Can you please create a ticket about enabled/disabled for TextFields?
👍 1
z

Zach Klippenstein (he/him) [MOD]

10/16/2020, 4:50 PM
(and please post here after, so we can star/follow it!)
d

dmnk_89

10/16/2020, 5:04 PM
https://issuetracker.google.com/issues/171040474
🙏 4
View count: 4