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

    Vsevolod Ganin

    09/20/2020, 12:40 PM
    Guys, I’m haunted with
    Class 'androidx.compose.ui.geometry.Offset' is compiled by a new Kotlin compiler backend and cannot be loaded by the old compiler
    . Please halp. I did everything including adding
    useIR = true
    ,
    freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
    in all places,
    compose true
    and all. How can I validate that IR is actually enabled? Using Kotlin 1.4.10, Compose 1.0.0-alpha03
    p
    • 2
    • 4
  • a

    Adriano Celentano

    09/20/2020, 12:44 PM
    Just went through all the
    LayoutModifier
    implementations just
    PainterModifier
    i didnt understand what its good for ?
    z
    n
    • 3
    • 5
  • v

    Vinay Gaba

    09/20/2020, 5:03 PM
    In the “Composable functions can run in parallel” section (https://developer.android.com/jetpack/compose/mental-model#parallel), I just noticed something
    Because of this, writes like this are not supported in Compose; by prohibiting those writes, we allow the framework to change threads to execute composable lambdas.
    I was wondering what “prohibiting those writes” means? Like I understand why we shouldn’t do it but how is the system enforcing it right now? I don’t see anything that’s stopping me from doing that.
    👀 2
    a
    • 2
    • 4
  • a

    andani

    09/20/2020, 7:44 PM
    Hi, I'm trying to animate the UI by changing ConstraintSet in ConstraintLayout. But it reflects the UI changes immediately without animating. Am I missing something or is it something not implemented yet? Thanks in advance. You can find the code in the thread.
    v
    h
    • 3
    • 12
  • l

    lib

    09/21/2020, 2:16 AM
    Why does compose feel so stuck ?
    🤔 6
    🙄 2
    v
    s
    t
    • 4
    • 3
  • p

    Prashant Priyadarshi

    09/21/2020, 6:44 AM
    Hello everyone, the below code is recomposing ui for every item in the list on scroll. This is being done even when there is no change is any of the items of list and number of items in list is 100 is there any way to avoid this
    ScrollableColumn() {
                    LazyColumnFor(items = list) {item ->
                        getSampleDataRow(data = item)
                    }
                }
    n
    y
    t
    • 4
    • 8
  • m

    Miguel Coleto

    09/21/2020, 8:21 AM
    Hi! I'm having some difficulties to understand how my components are being recomposed. I'm making a simple dice roller app and I want to animate every dice every time I produce a new roll. The thing is that if a dice gets the same result as the previous roll it won't animate again. This is working as expected I suppose. But there are sometimes when a new result won't animate the dice again and this I don't understand. I'd like to fix that and force the animation even if the result is the same
    y
    t
    • 3
    • 13
  • g

    georgiy.shur

    09/21/2020, 12:23 PM
    Hi. What is the best way to make an opaque color overlay over an image (safety gradient) in Compose? Creating a surface just for it seems like an overkill and it seems there is nothing like foreground modifier.
    m
    n
    • 3
    • 2
  • n

    Namig Tahmazli

    09/21/2020, 1:43 PM
    Same issue on Emulator with API 24 as well. I am really curious if this is a problem with AndroidView with MapView or AndroidView completely.
    r
    • 2
    • 1
  • m

    mattinger

    09/21/2020, 7:43 PM
    I do really like compose, but if it gets delivered with the preview as broken as it is now, it’s going to end up DOA.
    z
    h
    +2
    • 5
    • 10
  • j

    Jeremy

    09/22/2020, 2:36 AM
    Q: How can I make 2 columns. The first column a vertical line, the second column a text input. The first column height should be aligned with first.
    z
    t
    • 3
    • 4
  • b

    bruno.aybar

    09/22/2020, 5:39 AM
    Hello! I’ve been playing with
    transitions
    and
    transitionDefinitions
    for a sample app I'm working on. I noticed that I was having the same issues over an over while handling multiple transitions. Basically,
    transition(toState = , initState = )
    is a bit confusing at first try. It's great for a single animation that triggers immediately (i.e. the Rally app circular animation). However, it's easy for the state to get out of sync / to cause undesired transitions. I thought it may only be me, but I've seen the same problem in a post someone did. If you deep dive in the implementation, you'll notice: • Actual transitions work great. Really powerful API. • Problems: a) first transition is triggered right away. b) weird validations to display content because animating state and actual state are out of sync. With that I'm not trying to bash the author, of course, actually I had almost the exact same issues. Here I'm just pointing out a few ways in which I think the current API can be misused. There are solutions for those problems, yes, but I don't think they are that easy to figure out right now. So after dealing with some animations, I spotted a pattern with my implementations. Basically I had: • a class with the state. Same as in Jetsurvey app, which I used as example. • within that state, hold a
    current
    and
    animatingTo
    states. They work as the source of truth for the transition. That looked like the ideal solution for some of my transitions (not all of course, some work just fine without extra classes holding the state). Given that a lot of the logic was reused, I created a base implementation instead. Now, my question is: is this the correct approach? I really don't want to reinvent the wheel, or complicate things with unnecessary logic.
    d
    y
    • 3
    • 10
  • k

    kclerc

    09/22/2020, 3:10 PM
    👋 Both PaintStyle and DrawStyle expose
    Fill
    OR
    Stroke
    styles. In DrawScope’s
    drawPath
    method, documentation says :
    Whether this shape is
         * filled or stroked (or both) is controlled by [DrawStyle]
    What is the appropriate way to do the “both” scenario ? We could draw the path twice with two different DrawStyles but is there a cleaner solution to do that ?
    a
    n
    • 3
    • 3
  • h

    Henning B

    09/22/2020, 4:11 PM
    I got a problem with the State Codelab. In Chapter 6 you are building an input field which gets cleared when you press "add". but as soon you start typing again the text reappears. this seems buggy and I don't know why this is happening. I tested the finished solution from google but it also happens there. Did you also got this problem? why is this happening? Link: https://developer.android.com/codelabs/jetpack-compose-state?return=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fcompose%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fjetpack-compose-state#5
    s
    • 2
    • 13
  • b

    Brian Beale

    09/22/2020, 4:43 PM
    I can't figure out how to convert files from the MediaStore to one of the objects that the composable Image() expects. Is there a way to convert from a Descriptor, Bitmap, Drawable (w/o res id?) to ImageAsset or Painter?
    n
    • 2
    • 2
  • d

    Daniele B

    09/22/2020, 4:58 PM
    I am sharing also here, my experience about using Kotlin/React for creating Kotlin compose functions that look exactly like Jetpack Compose. Does anyone here have any info to share about future plans of extending JetpackCompose to the Web? It looks like a very natural road: https://kotlinlang.slack.com/archives/C3PQML5NU/p1600781686119000
    👍🏽 2
    f
    • 2
    • 1
  • n

    Nat Strangerweather

    09/22/2020, 5:32 PM
    Hi guys, another basic question, as I am still a beginner. I am trying to create custom radio buttons. I've looked at the code for RadioButtons but I can't see how to make sure that a button is deselected when another one is clicked. Here is my code:
    @Composable
    fun BoxCards(color: Color, gradientColor: Color, text: String, size: Dp) {
        val (selected, onSelected) = remember { mutableStateOf(false) }
        val tlRadius = animate(if (selected) 48.dp else 20.dp)
        val radius = animate(if (selected) 0.dp else 20.dp)
        val boxModifier = Modifier
            .size(size)
            .weight(1f)
            .clip(
                shape = RoundedCornerShape(
                    topLeft = tlRadius, topRight = radius,
                    bottomLeft = radius, bottomRight = tlRadius
                )
            )
            .toggleable(value = selected, onValueChange = onSelected)
            .background(
                VerticalGradient(
                    0.0f to color,
                    0.5f to gradientColor,
                    1.0f to color,
                    startY = 0.0f,
                    endY = with(DensityAmbient.current) { 150.dp.toPx() }
                )
            )
        Box(
            boxModifier,
            gravity = Center
        ) {
            Text(text = text, color = Color.White)
        }
    }
    I've used a tutorial by one of the Google team for the animation... Is there a simple way of converting my BoxCards into radio button behaviour?
    s
    • 2
    • 2
  • c

    caelum19

    09/23/2020, 11:08 AM
    Hey, how about having the ripple indication the default for .clickable? Seems a lot rarer that people wouldn't want it. Thoughts?
    l
    • 2
    • 2
  • s

    Sergey Y.

    09/23/2020, 12:12 PM
    Hooray! 🎉 1434551: Scroll performance optimization for LazyColumnFor/LazyRowFor | https://android-review.googlesource.com/c/platform/frameworks/support/+/1434551
    👍 5
    👌 13
    r
    j
    +2
    • 5
    • 5
  • g

    gpaligot

    09/23/2020, 12:33 PM
    Hello, I would like to know what is the recommended practice when we want to import and use an icon with Jetpack Compose? We should use a drawable or convert it in Kotlin? If it is the second one, there is any plan to migrate automatically a vector in Kotlin? Thanks in advance!
    l
    • 2
    • 2
  • r

    Roi Peretz

    09/23/2020, 2:20 PM
    Hi, can someone give me a recommendation of a good video course / tutorial of jetpack compose which contains all the new features and best practices until now?
    y
    a
    n
    • 4
    • 3
  • h

    Henning B

    09/23/2020, 4:07 PM
    No luck for me and compose codelabs 😞. I am currently doing the state codelab. Yesterday I posted about a problem where a TextField somehow remembers it's state. Problem only occured on one Samsung though. Now I am in the next chapter "7 Dynamic UI based on state". At the end an onClick action is extracted into a lambda variable and set when you press the "add" button or send an IME action via keyboard. The IME action doesnt work for me. In my code an empty Todo item is added, in the finished solution the "Done" button on the keyboard only closes the keyboard. This time the problem occurs on the Samsung and a current emulator. I would be interested if the IME functionality is working for anybody else and if I should invest time in troubleshooting ;)
    a
    j
    • 3
    • 4
  • a

    Ajeet Pratap

    09/23/2020, 8:24 PM
    Has anyone tried adding Jetpack Compose to existing KMM project. As soon I add the required dependencies for compose in the project gradle file, it just does not work. I am on Android Studio 4.2 C 12. Tried to copy the settings from perfectly working Compose examples, still no luck
    j
    s
    +2
    • 5
    • 6
  • g

    grandstaish

    09/23/2020, 8:59 PM
    How can I draw a dividers between
    Column
    children?
    p
    z
    +2
    • 5
    • 25
  • m

    Mohamed Elfiky

    09/24/2020, 1:27 AM
    what is the difference between
    modifier.clip(RoundedCornerShape(20.dp).background(Color.White)
    and
    modifier.background(color = Color.White, shape = RoundedCornerShape(20.dp))
    n
    c
    • 3
    • 18
  • c

    Colton Idle

    09/24/2020, 3:34 AM
    Trying to Toast inside of a composable event. How are you supposed to get a context?
    TextField(
                value = textState.value,
                onValueChange = { textState.value = it },
                imeAction = ImeAction.Done,
                onImeActionPerformed = { imeAction: ImeAction, softwareKeyboardController: SoftwareKeyboardController? ->
                    Toast.makeText(ContextAmbient.current, "asdf", Toast.LENGTH_SHORT).show()
                }
            )
    s
    • 2
    • 2
  • m

    Mohamed Elfiky

    09/24/2020, 3:39 AM
    is
    consumeScrollDelta
    lambda in
    ScrollableController
    receives the delta in
    dp
    now? or i am doing something wrong 😄
    m
    • 2
    • 1
  • b

    bruno.aybar

    09/24/2020, 5:16 AM
    Is there a reason why
    DirectionalAlignment
    is a private class? Being able to create an alignment with custom vertical and horizontal bias could be really useful. In my case I need to move a component around, and this seemed like the easiest way:
    @Composable
    fun Sample {
    
        val offset = animatedFloat(initVal = ...)
        onActive { offset.animateTo(...) }
    
        Stack {
            SomethingThatMoves(Modifier.align(DirectionalAlignment(offset.value,offset.value)))
        }
    }
    Given that it's private, I just copy & pasted the class, and worked perfectly. Is there another easy way to accomplish that?
    n
    m
    • 3
    • 8
  • q

    Quentin Dommerc

    09/24/2020, 12:44 PM
    Hey, any specific reason of why I can’t see the source code of any compose related class?
    ✅ 2
    👍 4
    s
    a
    +9
    • 12
    • 35
  • j

    Julius Marozas

    09/24/2020, 2:12 PM
    Hi, I am using an AlertDialog with a TextField and dismiss/confirm buttons. I have noticed that when the text field is in focus and keyboard is open the dismiss/confirm buttons are not interactive, i.e., their onClick event handlers are not called when they are clicked.
    • 1
    • 1
Powered by Linen
Title
j

Julius Marozas

09/24/2020, 2:12 PM
Hi, I am using an AlertDialog with a TextField and dismiss/confirm buttons. I have noticed that when the text field is in focus and keyboard is open the dismiss/confirm buttons are not interactive, i.e., their onClick event handlers are not called when they are clicked.
Here is the code https://gist.github.com/jul1u5/88b616b0fff627f6e58cd9fcf0855f52 and a recording showcasing the bug:
dialog-bug.mp4
View count: 7