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

    Jamie Craane

    10/09/2020, 2:54 PM
    Regarding this change: https://android-review.googlesource.com/c/platform/frameworks/support/+/1435797 is there a specific reason to let the drawing order affect the zOrder instead of an expliciet (and optional) zIndex parameter to the place* methods? When code in a custom layout is re-ordered (for whatever reason) this potentially breaks the layout. Or am I missing something here?
    a
    z
    • 3
    • 7
  • a

    Afzal Najam

    10/09/2020, 3:04 PM
    A question popped into my mind recently: how deep does the view hierarchy of Composables have to be to notice any performance hit?
    j
    i
    • 3
    • 3
  • w

    Wajahat Karim

    10/09/2020, 6:54 PM
    Hey folks, I wanted to play with animations in Compose. And I found that there are several ways to do it. But I couldn't find good comparisons and reasoning behind those. It got me confused and curious. That's why I put together different methods and prepared a talk on creating animations in Compose. I gave it at droidcon EMEA today. Just wanted to share it with you. Here are the slides and demo repository. Slides: https://slides.com/wajahatkarim/composeanimations Github: https://github.com/wajahatkarim3/droidcon2020
    ❤️ 3
    🎉 22
    z
    g
    +2
    • 5
    • 19
  • j

    jaqxues

    10/09/2020, 8:02 PM
    I have a Card + Switch. How do I handle the state so it toggles on onClick of the Card, and I can use an onCheckedChange correctly?
    a
    • 2
    • 25
  • a

    Adam Bennett

    10/10/2020, 9:53 AM
    Has anyone worked out a way to run an infinite animation with a specified delay between value changes? I'm using
    repeatable
    with
    AnimationConstants.Infinite
    and
    animatedFloat
    . I'm basically trying to force a canvas redraw every 300ms
    a
    z
    • 3
    • 4
  • d

    Davide Cazzorla

    10/10/2020, 11:20 AM
    Hello, I made this tinder like cards, hope you like it! Sorry for the spaghetti code, aiming to make it more clear and less buggy https://github.com/davideC00/CardStack
    👍 23
    a
    s
    v
    • 4
    • 10
  • s

    Se7eN

    10/10/2020, 3:41 PM
    I'm trying to use
    savedInstanceState
    with
    MutableState
    val themeColor by savedInstanceState(user) { mutableStateOf(Color.Blue) }
    but I'm getting this error:
    java.lang.IllegalArgumentException: Please use savedInstanceState() if you want to save a MutableState
    What am I doing wrong here?
    g
    z
    a
    • 4
    • 12
  • b

    blakelee

    10/11/2020, 3:12 AM
    I have a simple toggle that increment or decrements based on clicking + or -. The preview interaction doesn’t do anything but if I run it on device it works fine. Is there something that I’m missing in this example to make it work in the preview?
    @Preview
    @Composable
    fun Counter() {
        var count by remember { mutableStateOf(0) }
        Row {
            Image(vectorResource(R.drawable.ic_remove), Modifier.clickable { count-- })
            Text(text = count.toString(), modifier = Modifier.align(Alignment.CenterVertically))
            Image(vectorResource(R.drawable.ic_add), Modifier.clickable { count++ })
        }
    }
    g
    • 2
    • 3
  • p

    Prashant Priyadarshi

    10/11/2020, 6:58 AM
    Do we have a compose component for expandable search like in gmail and other apps something like https://stackoverflow.com/questions/29149268/how-to-implement-search-bar-like-gmail-app-in-android
    z
    w
    • 3
    • 3
  • z

    zoha131

    10/11/2020, 8:54 AM
    today i realized that the preview does not show AlertDialog…..
    g
    • 2
    • 1
  • c

    Ciprian Grigor

    10/11/2020, 9:48 AM
    Hi, any idea why android studio doesn't see the sources for jetpack androidx.compose.material library? AS 4.2 canary 13, compose 1.0.0-alpha04
    g
    • 2
    • 3
  • n

    Nat Strangerweather

    10/11/2020, 10:24 AM
    Hello, I made a custom switch with a number of size parameters. I would like to reuse that composable, but smaller. Is there a way of assigning a scale to the composable, or do I have to pass each size parameter along with the other function params? Here is what the switch looks like:
    @Composable
    fun CustomToggle(
        color: Color, gradientColor: Color, selected: Boolean,
        onSelected: () -> Unit
    ) {
    
        val toggleAlign = animate(if (selected) 65.dp else 5.dp)
    
        Box() {
            Box(
                modifier = Modifier
                    .height(40.dp)
                    .width(100.dp)
                    .clip(RoundedCornerShape(50))
                    .background(HorizontalGradient(
                        0.0f to color,
                        0.5f to gradientColor,
                        1.0f to color,
                        startX = 0.0f,
                        endX = with(DensityAmbient.current) { 100.dp.toPx() }
                    )
                    ),
            ) {}
            Surface(
                modifier = Modifier.size(30.dp)
                    .align(Alignment.CenterStart)
                    .offset(toggleAlign)
                    .clip(RoundedCornerShape(50))
                    .toggleable(value = selected, onValueChange = { onSelected() }),
                color = Color.White,
                elevation = 7.dp
            ) {}
        }
    }
    s
    g
    • 3
    • 5
  • s

    Se7eN

    10/11/2020, 12:32 PM
    I want to increase the progress of a
    LinearProgressIndicator
    over time. Like I want it to go from 0 to 100 in 3 seconds. How do I approach this?
    l
    c
    • 3
    • 5
  • v

    Vsevolod Ganin

    10/11/2020, 2:09 PM
    onCommit
    with input of some
    SnapshotMutableState
    doesn’t trigger its lambda when value changes.
    onCommit
    with
    SnapshotMutableState::value
    does. That’s more likely because
    SnapshotMutableState
    doesn’t implement and delegate
    equals
    to its
    value
    . Is this intentional behavior?
    a
    • 2
    • 28
  • o

    Oussama Haff.

    10/11/2020, 4:39 PM
    Hello everyone 👋 I’m trying to test my composables using androidTests, the tests passe correctly but all functions mentioned in the official doc are marked as
    deprecated
    without mentioning alternatives ! Am I missing something ? 🤔
    m
    • 2
    • 2
  • v

    Vinay Gaba

    10/11/2020, 7:32 PM
    https://twitter.com/vinaygaba/status/1315371644278325248
    🥇 21
    💯 18
    💪 4
    p
    c
    • 3
    • 2
  • a

    Alexander Karkossa

    10/12/2020, 6:58 PM
    Hey guys, since i switched to alpha04, i got these crash
    java.lang.IllegalStateException: Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied
            at androidx.compose.runtime.snapshots.SnapshotKt.readError(Snapshot.kt:1525)
            at androidx.compose.runtime.snapshots.SnapshotKt.readable(Snapshot.kt:1521)
            at androidx.compose.runtime.snapshots.SnapshotKt.readable(Snapshot.kt:1512)
            at androidx.compose.runtime.SnapshotMutableState.getValue(MutableState.kt:294)
            at androidx.compose.foundation.text.TextFieldState.getHasFocus(CoreTextField.kt:537)
            at androidx.compose.foundation.text.CoreTextFieldKt$CoreTextField$4$focusObserver$1.invoke(CoreTextField.kt:198)
            at androidx.compose.foundation.text.CoreTextFieldKt$CoreTextField$4$focusObserver$1.invoke(Unknown Source:3)
            at androidx.compose.ui.node.ModifiedFocusObserverNode.propagateFocusStateChange(ModifiedFocusObserverNode.kt:32)
    	....
    	    at androidx.compose.runtime.Composer.recomposeToGroupEnd(Composer.kt:1560)
            at androidx.compose.runtime.Composer.skipToGroupEnd(Composer.kt:1784)
            at androidx.compose.ui.LayoutKt.WithConstraints(Layout.kt:532)
            at androidx.compose.material.DrawerKt.BottomDrawerLayout-rxTpieo(Drawer.kt:427)
            at de.charlex.xxx.ui.MyAppKt$MyAppContent$1.invoke(MyApp.kt:171)                       <----- Thats the first line in stacktrace where my sources are referenced.
    Line MyApp.kt:171:
    BottomDrawerLayout(
    I was not able to find the reason. If i remove the BottomDrawerLayout, the app don't crash anymore. I tried another app, added a BottomDrawerLayout there and .... it worked fine... I think the reason for the crash is not the BottomDrawerLayout. Any ideas?
    c
    • 2
    • 2
  • c

    caelum19

    10/12/2020, 7:20 PM
    Is anyone aware of a "Tutorial" composable that highlights other composables with descriptions?
    🇳🇴 1
    z
    • 2
    • 2
  • s

    spierce7

    10/12/2020, 7:33 PM
    Did anyone hear anything about multiplatform compose at the online Kotlin event today?
    s
    t
    • 3
    • 5
  • g

    Guy Bieber

    10/12/2020, 9:27 PM
    Any schedule for a feature complete beta release?
    g
    • 2
    • 1
  • h

    Halil Ozercan

    10/12/2020, 9:39 PM
    I gave it a shot this weekend to implement a markdown renderer in Jetpack Compose. Thanks to
    compose-richtext
    and abundance of Markdown parsers, I was able to have a working prototype in 2 evenings. Hopefully I can share the code once it is more organized and readable.

    https://youtu.be/Mrts0NdIcbE▾

    👏 2
    🎉 20
    c
    k
    +5
    • 8
    • 7
  • i

    Irving

    10/13/2020, 11:22 AM
    Hello, I read the source code of
    CircularProgressIndicator
    to learn how to write a custom view.But I'm confused about the
    Modifier.semantics
    . I thought it's
    SemanticsModifierCore
    may store the properties of `CircularProgressIndicator`,but i did't see anything about
    SemanticsModifierCore
    in
    CircularProgressIndicator
    .So what does
    Modifier.semantics
    do for us?😢
    a
    a
    • 3
    • 4
  • a

    Alexander Karkossa

    10/13/2020, 12:31 PM
    Hey guys, i have a question. I tried to use an app-wide Scaffold with NavHost (from the navigation Snapshot Library) in its content. Each view should be able to edit the state of the bottomAppBar and the fab. (Show Fab, disable BottomDrawerLayout Gesture, hide BottomAppBar and so on) I tried the following, but i doesn't work. When i try to navigate to the LoginScreen, the changes in the bottomAppBarConfig and the fabConfig are triggering a complete redraw and the NavHost will also be recreated. Even before i try to navigate the hole tree recreates in a loop because of the config change for the first view How to do it correctly? I dont want to set the Scaffold per view because the app contains nearly 40 views...
    a
    a
    • 3
    • 21
  • r

    Robert Menke

    10/13/2020, 1:50 PM
    Is
    PasswordTextField
    depcreated?
    a
    • 2
    • 2
  • p

    Pedro Gomez

    10/13/2020, 2:17 PM
    Hi all! I'm writing an app and adding screenshot tests for my components and I'm facing some issues with the RoundedCornerShape. When using a shape for the component background the rendering result is not the changes a little bit and this makes the screenshot test tool to report there is an error in the rendering. The shape I'm using is this
    RoundedCornerShape(size = 16.dp)
    The error reported by the screenshot testing shows a bunch of small different pixels making the tests fail. Red dots in the screenshot are the errors reported by the testing tool. Do you know if the rendering can vary depending on the build or any other param?
    a
    j
    +3
    • 6
    • 53
  • h

    Hitanshu Dhawan

    10/13/2020, 4:08 PM
    Hey guys, wanted your thoughts on implementing this UI with compose. • Text is 70% of width • Then image takes rest width and is slightly outside of the card. So, whats the best way to implement this? Stack/Box? Constraint Layout? etc.
    👍 1
    v
    n
    +3
    • 6
    • 22
  • s

    Se7eN

    10/13/2020, 4:50 PM
    So I have this code:
    val emojiState = remember { mutableStateOf(EmojiState.HIDDEN) }
    val definition = transitionDefinition<EmojiState> {
        state(EmojiState.HIDDEN) {
            this[emojiSize] = 0.dp
        }
    
        state(EmojiState.START) {
            this[emojiSize] = 20.dp
        }
    
        state(EmojiState.END) {
            this[emojiSize] = 50.dp
        }
    
        transition(fromState = EmojiState.START, toState = EmojiState.END) {
            interruptionHandling = InterruptionHandling.SNAP_TO_END
            emojiSize using tween(3000, easing = FastOutSlowInEasing)
        }
    }
    
    val transitionState = transition(
        definition = createEmojiTransition(),
        initState = emojiState.value,
        toState = if (emojiState.value == EmojiState.START) EmojiState.END else EmojiState.HIDDEN,
        onStateChangeFinished = {
            emojiState.value = it
        }
    )
    When I change
    emojiState
    to
    HIDDEN
    while the transition from
    START
    to
    END
    is going on, it looks like the transition isn't interrupted and still going on in the background. For example, I change the transition to
    HIDDEN
    1000 millis after starting the
    START
    to
    END
    transition, then after 2000 millis the
    onStateChangeFinished
    is run and it sets my state back to
    END
    . Is there some way I can interrupt the transition and prevent
    onStateChangeFinished
    to be called for interrupted transitions. Or maybe my logic is at fault here?
    a
    b
    d
    • 4
    • 9
  • m

    Mohammad Sianaki

    10/13/2020, 6:33 PM
    Hey guys! How can I save and restore a
    LazyColumn
    or
    LazyRow
    scroll position across process death?
    b
    a
    • 3
    • 2
  • s

    Sebastian Neagrau

    10/13/2020, 9:08 PM
    Is it possible to add a Gradient Background to a Button? I tried adding a gradient to a Column and set the Column as the content of the button and set the button’s background color to Transparent, and I can see the gradient but for some reason I still have some paddings (even though they are set to 0).
    n
    • 2
    • 1
  • b

    bruno.aybar

    10/14/2020, 4:51 AM
    When using
    OutlinedTextField
    , is there any way to always keep the label at the top , instead of having it inside when the text is empty / unfocused? I know the answer here usually is that that's the recommended material behavior, however, in this case I feel that such a small change is not worth creating a new
    TextFieldImpl
    implementation (but of course, I may be wrong).
    s
    • 2
    • 4
Powered by Linen
Title
b

bruno.aybar

10/14/2020, 4:51 AM
When using
OutlinedTextField
, is there any way to always keep the label at the top , instead of having it inside when the text is empty / unfocused? I know the answer here usually is that that's the recommended material behavior, however, in this case I feel that such a small change is not worth creating a new
TextFieldImpl
implementation (but of course, I may be wrong).
s

Siyamed

10/14/2020, 4:52 AM
There is no end for specific requests :/
As far as i know as you also mentioned the material textfields strictly follow the material guidelines
Actually it applies to all/most of the material layer
b

bruno.aybar

10/14/2020, 5:04 AM
You're right, I see how those specific requests can get out of hand. Totally get the logic behind that. At the end, my real problem here was that I was looking at
TextFieldImpl
by mistake, instead of looking at
BaseTextField
which makes much more sense here and with little work can cover my use case 😅
👍 1
View count: 3