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

    Julius Marozas

    07/23/2020, 9:52 PM
    I am having an issue with the new Compose version (0.1.0-dev15) in Android Studio. My project builds fine, but Studio shows warnings near things such as `MaterialTheme.colors.surface`:
    'surface: Color' is only available since Kotlin 1.4 and cannot be used in Kotlin 1.3
    I have also set the "Update channel" in Languages & Frameworks > Kotlin (Android Studio settings) to "Early Access Preview 1.4.x".
    a
    p
    a
    • 4
    • 12
  • s

    shikasd

    07/23/2020, 10:30 PM
    Hey, does compose provide functionality to "attach"/"detach" layout nodes? Basic example is routing: we have a list with some heavy animation running on screen -> open detail of list item on top. In that case it will be great to not draw the background screen anymore but keep scroll state of the list. Currently two solutions I've seen is to either draw screens on top of each other (quite inefficient), or just switch composables completely (doesn't keep the state). Maybe there are some interesting methods of making pieces of composition detached (not drawing them) while keeping the state?
    z
    t
    +3
    • 6
    • 41
  • a

    amar_1995

    07/24/2020, 7:48 AM
    I need to add badge on icon image. Is there any example to do that.
    p
    • 2
    • 2
  • g

    galex

    07/24/2020, 10:12 AM
    Basically I would like to animate the rect of the root Composable till it reaches its full size, any pointers? 😊
    m
    f
    d
    • 4
    • 21
  • b

    BenjO

    07/24/2020, 11:41 AM
    Hey everyone, I’m trying to understand why a recomposition occurs. As a dumb example, let’s say I have a
    Foobar
    composable displaying
    Foo
    and
    Bar
    children composables.
    Foobar
    has two state variables.
    @Composable
    fun Foobar(fooFlow: StateFlow<Long>, barFlow: StateFlow<Long>) {
        val foo by fooFlow.collectAsState()
        val bar by barFlow.collectAsState()
    
        Column {
            Foo(foo)
            Bar(bar)
        }
    }
    
    @Composable
    fun Foo(value: Long) {
        Text("Foo $value")
    }
    
    @Composable
    fun Bar(value: Long) {
        Text("Bar $value")
    }
    Every time either
    fooFlow
    or
    barFlow
    receives a new value, both
    Foo
    and
    Bar
    are recomposed (onCommit is triggered) . I was hoping that only the composable using the flow value would be refreshed. The only solution I see is to pass each StateFlow down to the children. I’m I correct ?
    z
    l
    • 3
    • 21
  • a

    Archie

    07/24/2020, 12:58 PM
    How to you keep the value of
    state { ... }
    across configuration changes?
    z
    m
    +3
    • 6
    • 14
  • j

    Jorge Castillo

    07/24/2020, 1:43 PM
    Hi. What you'd use to get the position of a composable on screen relative to the parent? as in: view.top / view.bottom etc.
    Layout
    ?
    a
    • 2
    • 13
  • m

    Marcin Środa

    07/24/2020, 2:09 PM
    Has anyone noticed instability after updating to dev15? My app starts crashing silently while using FilledTextField.
    2020-07-24 16:05:59.308 582-659/system_process W/InputDispatcher: channel '5963efc .ui.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
    2020-07-24 16:05:59.308 582-659/system_process E/InputDispatcher: channel '5963efc ui.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
    • 1
    • 3
  • m

    Mohamed Elfiky

    07/24/2020, 3:18 PM
    is there a way to modfiy CircularProgressIndicator innerPadding and the color of the remaining progress?
    a
    h
    a
    • 4
    • 3
  • h

    Halil Ozercan

    07/24/2020, 3:52 PM
    I'm getting this weird error while trying to compile
    Comparison of incompatible enums 'Direction' and '[ERROR : Direction.LEFT]' is always unsuccessful
    Android Studio doesn't show any errors though. The offending line is #4
    .dragGestureFilter(
            dragObserver = dragObserver,
            canDrag = {
                it == Direction.LEFT || it == Direction.RIGHT
            }
    )
    • 1
    • 1
  • d

    David Mcrae Jr

    07/24/2020, 5:58 PM
    Anyone have a good example showing a Data Class -> ViewModel -> Composable View with a FilledTextField (or any text field for that matter)? Most example projects don’t show data input…. Thanks in advance
    b
    j
    • 3
    • 2
  • b

    bohregard

    07/24/2020, 10:14 PM
    I’m running into issues with the latest version of Android Studio and the Kotlin 1.4-M3 plugin. Is this expected? The build compiles with no issues, it’s just really driving me up the wall to see so many red squiggles
    j
    t
    • 3
    • 15
  • h

    henrikhorbovyi

    07/25/2020, 5:24 AM
    Is it possible to use Compose with a non androidx project. I mean, I'm contributing to a project (Koin to be specific) and I'd like to add a module running compose to add some feature to the whole project, but compose complains that my project is not androidx I should add:
    android.useAndroidX=true
    android.enableJetifier=true
    To the gradle.properties, but it would impact imports in the entire project 😞 I've tried to add a gradle.properties for the specific module, but it didn't work
    g
    i
    t
    • 4
    • 11
  • m

    Mehdi Haghgoo

    07/25/2020, 9:22 AM
    Is it possible to use a custom font ( a ttf file I added to the font res directory) with Jetpack Text()? I have failed so far to do so!
    a
    a
    • 3
    • 2
  • p

    Philip Blandford

    07/25/2020, 2:30 PM
    Seem to have a bug with OutlinedTextField in Popups - it crashes after a couple of key strokes (dev15)
    d
    • 2
    • 1
  • t

    tjohnn

    07/25/2020, 5:43 PM
    A simple gridview implementation with compose, anyone?
    t
    • 2
    • 2
  • t

    tjohnn

    07/25/2020, 5:54 PM
    Another question, why is it that paddings on
    Card
    's are somehow showing as margins? Am I getting it wrong?
    a
    m
    • 3
    • 9
  • h

    henrikhorbovyi

    07/25/2020, 7:11 PM
    I'm updating from
    dev14
    ->
    dev15
    and I got the following error: Any ideas?
    i
    j
    m
    • 4
    • 4
  • v

    Vinay Gaba

    07/25/2020, 7:52 PM
    Hello wonderful people 👋🏼 I started collecting and answering some “Frequently Asked Questions” about Compose. I would love to know which other questions I should be adding to this list. You can find it here 👉🏼 https://JetpackCompose.app/faq. Also if you think any information is incorrect, please let me know!
    👏 12
    🔥 1
    ❤️ 8
    z
    b
    +3
    • 6
    • 21
  • a

    andylamax

    07/26/2020, 5:22 AM
    To avoid too much indentation, I write my code like this,
    @Composable
    fun Widget() = Column(modifier = Modifier.fillMaxSize()) {
      Text(
        text = "First item",
        modifier = Modifier.padding(16.dp)
      )
      Text(
        text = "Second item",
        modifier = Modifier.padding(16.dp)
      )
      Text(
        text = "Third item",
        modifier = Modifier.padding(16.dp)
      )
    }
    Is there a caveat?
    t
    • 2
    • 2
  • a

    Archie

    07/26/2020, 12:31 PM
    So I found that you could create a
    ViewModel
    in
    Compose
    using
    viewModel()
    composable function. I was wondering how to scope these
    ViewModel
    similar to how
    ViewModel
    could be scoped to
    Activity
    /
    Fragment
    or
    NavGraph
    ? Is this possible to do in
    Compose
    ?
    m
    a
    +3
    • 6
    • 7
  • a

    Archie

    07/26/2020, 2:58 PM
    Lets say I have this code:
    @Composable
    fun Greetings() {
        val state = state { "Hello" }
        Column {
            Text(text = state.value)
            Button(onClick = {
                state.value = "Hello"
            }) {
                Text(text = "Greet!")
            }
        }
    }
    Notice that the initial value of state is "Hello" and whenever the Button is clicked, it sets the value of the state to the same value (
    state.value = "Hello"
    ). Does this trigger recomposition? or recomposition is only triggered when
    state
    is set with a different value? Also is there a hook or callback I could attach to see how recomposition works in
    compose
    ?
    a
    r
    • 3
    • 23
  • f

    Fudge

    07/26/2020, 3:13 PM
    "Frames have been replaced by snapshots" What does this mean? I didn't see anything about this in the release notes.
    a
    l
    • 3
    • 6
  • g

    galex

    07/26/2020, 3:31 PM
    What’s the best way to have a button or anything just centered inside its parent (which is the
    bodyContent
    of Scaffold in my case) ?
    a
    • 2
    • 8
  • b

    brandonmcansh

    07/26/2020, 4:25 PM
    Is anyone else having issues with interactive preview generating a preview? It constantly says "The project needs to be compiled for the preview to be displayed" or that it needs to be refreshed
    g
    p
    b
    • 4
    • 10
  • f

    Fudge

    07/26/2020, 4:33 PM
    I wonder, is it possible to do something like this?
    @Composable suspend fun askQuestion() : Answer {
       return suspendCoroutine { continuation -> 
          QuestionComponent(onAnswer = {answer -> continuation.resume(answer)})
       }
    }
    The problem is that if I do something like this
    setContent {
        runBlocking { askQuestion() }
    }
    It won't compile because "@Composable invocations can only happen from the context of a @Composable function"
    a
    l
    • 3
    • 20
  • g

    galex

    07/26/2020, 5:07 PM
    I used the Google icon with colors as SVG but using it as
    Icon(vectorResource(id = R.drawable.ic_google))
    shows it as a black rectangle, I guess its the icon trying to tint it? Here’s the SVG:
    <vector xmlns:android="<http://schemas.android.com/apk/res/android>"
        android:width="23dp"
        android:height="23dp"
        android:viewportWidth="46"
        android:viewportHeight="46">
        <path
            android:fillColor="#4285F4"
            android:fillType="evenOdd"
            android:pathData="M5,3L41,3A2,2 0,0 1,43 5L43,41A2,2 0,0 1,41 43L5,43A2,2 0,0 1,3 41L3,5A2,2 0,0 1,5 3z"
            android:strokeWidth="1"
            android:strokeColor="#00000000" />
        <path
            android:fillColor="#FFFFFF"
            android:fillType="evenOdd"
            android:pathData="M5,4L41,4A1,1 0,0 1,42 5L42,41A1,1 0,0 1,41 42L5,42A1,1 0,0 1,4 41L4,5A1,1 0,0 1,5 4z"
            android:strokeWidth="1"
            android:strokeColor="#00000000" />
        <path
            android:fillColor="#4285F4"
            android:fillType="evenOdd"
            android:pathData="M31.64,23.2045C31.64,22.5664 31.5827,21.9527 31.4764,21.3636L23,21.3636L23,24.845L27.8436,24.845C27.635,25.97 27.0009,26.9232 26.0477,27.5614L26.0477,29.8195L28.9564,29.8195C30.6582,28.2527 31.64,25.9455 31.64,23.2045L31.64,23.2045Z"
            android:strokeWidth="1"
            android:strokeColor="#00000000" />
        <path
            android:fillColor="#34A853"
            android:fillType="evenOdd"
            android:pathData="M23,32C25.43,32 27.4673,31.1941 28.9564,29.8195L26.0477,27.5614C25.2418,28.1014 24.2109,28.4205 23,28.4205C20.6559,28.4205 18.6718,26.8373 17.9641,24.71L14.9573,24.71L14.9573,27.0418C16.4382,29.9832 19.4818,32 23,32L23,32Z"
            android:strokeWidth="1"
            android:strokeColor="#00000000" />
        <path
            android:fillColor="#FBBC05"
            android:fillType="evenOdd"
            android:pathData="M17.9641,24.71C17.7841,24.17 17.6818,23.5932 17.6818,23C17.6818,22.4068 17.7841,21.83 17.9641,21.29L17.9641,18.9582L14.9573,18.9582C14.3477,20.1732 14,21.5477 14,23C14,24.4523 14.3477,25.8268 14.9573,27.0418L17.9641,24.71L17.9641,24.71Z"
            android:strokeWidth="1"
            android:strokeColor="#00000000" />
        <path
            android:fillColor="#EA4335"
            android:fillType="evenOdd"
            android:pathData="M23,17.5795C24.3214,17.5795 25.5077,18.0336 26.4405,18.9255L29.0218,16.3441C27.4632,14.8918 25.4259,14 23,14C19.4818,14 16.4382,16.0168 14.9573,18.9582L17.9641,21.29C18.6718,19.1627 20.6559,17.5795 23,17.5795L23,17.5795Z"
            android:strokeWidth="1"
            android:strokeColor="#00000000" />
    </vector>
    p
    • 2
    • 3
  • w

    William Barbosa

    07/27/2020, 12:59 PM
    Compose question: I wanna have an edge-to-edge app and I want to add the navigation bar height as bottom padding to a scroll list so that the last item doesn't get cut. Right now, I'm checking if
    item == lastItem
    inside the loop and updating the bottom padding accordingly. Is there a way of doing what we did in xml files by adding
    android:clipToPadding="false"
    so that the padding was always added at the end of the scroll or is checking item by item the Compose Way™️? 🤔
    t
    • 2
    • 6
  • h

    Horv

    07/27/2020, 1:05 PM
    I'm trying to add Jetpack Compose to my existing pet project. Got stuck getting the following error:
    jetified-kotlin-stdlib-1.3.72.jar: Runtime JAR file has version 1.3 which is older than required for API version 1.4
    Using latest stable Kotlin plugin for Android Studio. Do I need to switch to 1.4 preview?
    a
    t
    • 3
    • 5
  • f

    Fudge

    07/27/2020, 1:46 PM
    Looks like upgrading the kotlin plugin to 1.4 rc broke my project 🙂
    b
    h
    a
    • 4
    • 17
Powered by Linen
Title
f

Fudge

07/27/2020, 1:46 PM
Looks like upgrading the kotlin plugin to 1.4 rc broke my project 🙂
b

brandonmcansh

07/27/2020, 2:04 PM
android {
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion "${compose_version}"
        kotlinCompilerVersion "1.4.0-dev-withExperimentalGoogleExtensions-20200720"
    }
}
Did you update the compiler version?
h

Horv

07/27/2020, 2:11 PM
Having the same issue when adding Jetpack Compose to my project. I have the compiler version in my configuration.
b

brandonmcansh

07/27/2020, 2:11 PM
is your project single module or multi? It has to be applied to all modules
h

Horv

07/27/2020, 2:18 PM
Single (just
app
included). You can view my current experimentation here: https://github.com/fredagsdeploy/cheer-with-me/tree/feature/jetpack-compose/android if that's any help. I've more or less copied the sample here https://github.com/romainguy/sample-materials-shop for the gradle configuration
And I'm running Android Studio Canary :
Android Studio 4.2 Canary 5
Build #AI-201.7846.76.42.6682321, built on July 15, 2020
Runtime version: 1.8.0_242-release-1644-b01 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1237M
Cores: 24
Non-Bundled Plugins: org.jetbrains.kotlin
b

brandonmcansh

07/27/2020, 2:21 PM
interesting next question was gonna be the compiler arg to skip pre release checks but you have that too
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
    }
}
wondering if we need an updated compiler version
h

Horv

07/27/2020, 2:36 PM
Hmm, I didn't change anything (just fiddled back and forth with Kotlin-plugin settings etc) and now the Android Studio errors are gone. Still stuck on compiler error when trying to build though.
Or nevermind. Just doing any code change re-triggered the Android studio errors
b

brandonmcansh

07/27/2020, 2:57 PM
ah
f

Fudge

07/27/2020, 2:59 PM
Changing kotlin version in buildscript to 1.4.0-rc fixed it
❤️ 2
b

brandonmcansh

07/27/2020, 3:00 PM
ah nice find
h

Horv

07/27/2020, 3:30 PM
Ah, nice! Now I just need to find out how to debug my internal compilation error. 😕
a

allan.conda

07/27/2020, 9:21 PM
Changing kotlin version in buildscript to 1.4.0-rc fixed it
Awesome find, seems the problem occured due to this recent kotlin plugin update. Compose should probably update the instructions here: https://developer.android.com/jetpack/androidx/releases/compose
b

brandonmcansh

07/27/2020, 9:21 PM
+1
a

allan.conda

07/27/2020, 9:25 PM
probably should update coroutines as well to
1.3.8-1.4.0-rc
View count: 1