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

    Sergey Y.

    09/02/2020, 9:57 PM
    Maybe a noob question. But what is the replacement of Android's Selector(Drawable State List) in Compose? I want to make a button that looks differently under certain conditions.
    Pressed
    ,
    enabled
    ,
    disabled
    ,
    focused
    ,
    hovered
    , etc.
    👀 2
    s
    z
    l
    • 4
    • 34
  • b

    blakelee

    09/03/2020, 5:29 AM
    I just want to say that I watched the thinking in compose video and it blew my mind. Thank you Android team!
    👍 2
    🎉 3
    y
    • 2
    • 1
  • i

    immathan

    09/03/2020, 6:07 AM
    Hello everyone! When recomposing is triggered on a click of a
    Card
    , the
    backgroundColor
    property is getting changed based on the condition, but not the
    border
    .
    fun CardDisplay() {
        val selected = remember { mutableStateOf(true) }
        Surface(modifier = Modifier.fillMaxSize().gravity(Alignment.CenterVertically)) {
            Card(
                modifier = Modifier
                    .size(32.dp).clickable(onClick = {
                        selected.value = !selected.value
                    }),
                backgroundColor = if (selected.value) Color.Red else Color.Black,
                border = if (selected.value) BorderStroke(2.dp, Color.Green) else null,
            ) {
    
            }
        }
    }
    If you notice the
    cardbug.mp4
    video, the
    border
    property is not reflected since the green color border is not going off. But I tried changing the
    border
    width to
    0.dp
    and it’s working as expected. Is this the expected behaviour?
    border = if (selected.value) BorderStroke(2.dp, Color.Green) else BorderStroke(0.dp, Color.Green),
    cardbug2.mp4cardbug.mp4
    v
    • 2
    • 3
  • a

    allan.conda

    09/03/2020, 6:39 AM
    Reading codelabs… It says
    TextField
    is stateless, but
    TextFieldImpl
    as a bunch of mutable states internally. How do we know if a Composable is stateless or not?
    👀 1
    👍 1
    a
    s
    • 3
    • 15
  • k

    kclerc

    09/03/2020, 7:13 AM
    Hi, how do accessibility features work with compose ? Are there any resources about that ?
    a
    • 2
    • 1
  • s

    Sergey Y.

    09/03/2020, 10:45 AM
    1413667: Prototype: Coroutine scrolling APIs | https://android-review.googlesource.com/c/platform/frameworks/support/+/1413667 very interesting... 🤔
    :yes: 1
    a
    l
    • 3
    • 41
  • d

    Daniele B

    09/03/2020, 11:58 AM
    I am developing a master/detail app, with a
    LazyColumnFor
    showing a list of items on the master screen. When click on an item to access the detail screen, and then I come back to the master screen, the position of the list is not kept. It is always reset to the top. Is there a way to keep the position of the
    LazyColumnFor
    ?
    a
    t
    a
    • 4
    • 9
  • j

    Jeff Jackson

    09/03/2020, 3:52 PM
    Tried both - same issue
    p
    c
    • 3
    • 6
  • j

    John O'Reilly

    09/03/2020, 4:27 PM
    Is anyone else that's using https://github.com/zsoltk/compose-router getting "Backend Internal error: Exception during code generation" build error after updating to alpha02? I've commented out it's use and it's building fine.
    d
    • 2
    • 3
  • j

    Jan Skrasek

    09/03/2020, 5:29 PM
    by remember {  }
    property delegate was removed? or any idea why it is not working?
    Type 'TypeVariable(T)' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
    • AS 4.2.0-alpha09 • Compose 1.0.0-alpha02 Maybe the issue is AS cannot find the declaration of remember (though suggesting it in autocomplete) (import androidx.compose.runtime.rememberimport androidx.compose.runtime.remember)
    j
    m
    +4
    • 7
    • 11
  • m

    manueldidonna

    09/03/2020, 9:57 PM
    How to mark external classes (imported from libraries or modules which don't depend on compose) as
    Stable/Immutable
    ? I know that the public properties of that classes won't change
    a
    l
    j
    • 4
    • 8
  • y

    Yamila Gammeri

    09/04/2020, 3:29 AM
    For some reason, my selectedNavigationTab resets itself to the initial value instead of retaining when a new navigationTab is selected. This occurs when the SignedInView is re-rendered on a theme change. What could I be doing wrong, this was working when I used the now removed 
    state { xx }
    a
    • 2
    • 2
  • k

    Ketan

    09/04/2020, 6:33 AM
    TextField
    - How can I style the underline colour, error text colour? Is there any attribute that I can set and it styles the
    TextField
    the way I want?
    Card(color = MaterialTheme.colors.onBackground,
                    elevation = 16.dp,
                    modifier = Modifier.fillMaxWidth()
                        .height(160.dp)
                ) {
                    Column(modifier = Modifier.fillMaxWidth()
                        .padding(horizontal = 32.dp),
                        verticalArrangement = Arrangement.Center,
                        horizontalGravity = Alignment.CenterHorizontally
                    ) {
                        TextField(value = TextFieldValue("User"),
                            modifier = Modifier.preferredHeight(48.dp),
                            cursorColor = MaterialTheme.colors.background,
                            textColor = MaterialTheme.colors.background,
                            onValueChange = {})
                        Spacer(modifier = Modifier.height(16.dp))
                        TextField(value = TextFieldValue("Password"),
                            modifier = Modifier.preferredHeight(48.dp),
                            cursorColor = MaterialTheme.colors.background,
                            textColor = MaterialTheme.colors.background,
                            visualTransformation = PasswordVisualTransformation(),
                            onValueChange = {})
                        
                    }
                }
                Spacer(modifier = Modifier.height(16.dp))
                Row(modifier = Modifier.fillMaxWidth(),
                    horizontalArrangement = Arrangement.End,
                    verticalGravity = Alignment.CenterVertically
                ) {
                    OutlinedButton(onClick = {},
                        elevation = 16.dp,
                        border = Border(2.dp, color = MaterialTheme.colors.onBackground)
                    ) {
                        Text(text = "Reset", color = MaterialTheme.colors.onBackground)
                    }
                    Spacer(modifier = Modifier.width(16.dp))
                    Button(onClick = {},
                        elevation = 16.dp,
                        backgroundColor = MaterialTheme.colors.onBackground,
                    ) {
                        Text(text = "Login")
                    }
                }
    The above code produces
    s
    k
    • 3
    • 3
  • k

    Ketan

    09/04/2020, 6:36 AM
    Lot of things missing in
    TextField
    compare to
    EditText
    Material. Some basic things should be provided to style the look and feel.
    🤔 1
    z
    n
    +4
    • 7
    • 30
  • m

    Matej Drobnič

    09/04/2020, 12:48 PM
    Are there any samples out there of list item animations? Similarly to what
    RecylerView
    does when you add/remove/update/move items around. Is this even possible at this moment?
    👀 1
    v
    j
    • 3
    • 10
  • n

    Neil

    09/04/2020, 1:32 PM
    I was trying the Material TextField and OutlinedTextField and noticed some odd behaviour. On selecting the fields the cursor is very small and jumps in size once you enter text. Also the vertical size of the TextField increases, as can be seen in this gif. I found that if I set the
    textStyle = MaterialTheme.typography.body2
    for these components the problem went away. Is this expected behaviour?
    d
    • 2
    • 3
  • d

    Dominaezzz

    09/04/2020, 1:34 PM
    Does compose work in stable Android Studio yet? Since it doesn't need the custom Kotlin compiler build anymore.
    a
    z
    +3
    • 6
    • 11
  • j

    JCollardBovy

    09/04/2020, 3:04 PM
    Folks did anyone manage to get Serialization working along compose (in the same module)? I browsed through the history and saw multiple comments on the topic but there aren't any comments on the last 2 weeks
    a
    • 2
    • 3
  • s

    Sheroz Nazhmudinov

    09/04/2020, 6:25 PM
    hey i’m trying out the constraint layout in jetpack compose. Here are my gradle dependencies:
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.ui:ui-tooling:$compose_version"
    implementation "androidx.compose.foundation:foundation:$compose_version"
    implementation "androidx.compose.ui:ui:$compose_version"
    And here’s the basic attempt on using ConstraintLayout:
    @Composable
    @Preview
    fun PreviewGreeting() {
        ConstraintLayout(constraintSet = ConstraintSet {
            tag("someTag")
        }) {
            Greeting(greeting = "Hello world")
        }
    }
    I get the error thou saying unresolved reference tag. can smbd please tell me which dependency am I missing?
    r
    n
    • 3
    • 9
  • z

    Zach Klippenstein (he/him) [MOD]

    09/04/2020, 6:57 PM
    Just released a library for pretty-printing view hierarchies, and it supports composables too. Until LayoutInspector properly works with Compose, this might be helpful for debugging Compose apps. Feedback welcome! Note that it doesn’t actually depend on a specific version of Compose, it tries to be somewhat flexible about supporting at least a few recent versions. Github: https://github.com/square/radiography/ Blog: https://developer.squareup.com/blog/introducing-radiography/ Example output:
    Untitled
    📻 1
    👍 1
    🆒 1
    🎉 33
    🔥 9
    ☠️ 1
    c
    k
    • 3
    • 5
  • a

    Artem Kopan

    09/04/2020, 8:09 PM
    Hi everyone, how to make text scrollable?
    z
    a
    • 3
    • 4
  • j

    John O'Reilly

    09/04/2020, 9:17 PM
    Using the
    Crane
    sample as a template I'm making another pass at including a Google Map in Compose UI....I think this came up before but if I set
    uiSettings.isZoomControlsEnabled
    the zoom controls show on map but touching them doesn't do anything. The Crane sample sets up custom zoom controls outside map for what I'm guessing is the same reason ``````
    d
    • 2
    • 7
  • j

    jaqxues

    09/04/2020, 9:27 PM
    I use a LazyColumnFor with expanding Contents. There are 4 collapsed Items, which will take up the entire screen when expanded. Now when you scroll down and collapse an item, it will not scroll automatically up. Is this behaviour intended? (I don't think so, since it can cause exceptions (-> Thread)). Is this a known issue?
    a
    • 2
    • 5
  • s

    Sergey Y.

    09/04/2020, 10:42 PM
    Hello again. I am making my first attempts at animating in Compose. I have achieved the desired result, but the implementation does not suit me. The code is cumbersome and a little confusing. Does not look declarative. I believe there are better ways to achieve results with less effort, as you can see in the video. But I can't comprehend it. I hope for your help. Thank you in advance. The code: https://gist.github.com/sergeyfitis/c40e2b1a2b7c929da488f85e1d4c514f
    compose_animation.mp4
    • 1
    • 1
  • d

    Daniele B

    09/05/2020, 12:36 PM
    Is a “loading wheel” icon available in Compose? to show in a loading screen
    j
    • 2
    • 2
  • j

    Julius Marozas

    09/05/2020, 1:26 PM
    Why can I only decorate one parameter with
    @PreviewParameter
    ? Is this going to change in the future?
    a
    y
    • 3
    • 4
  • o

    Orhan Tozan

    09/05/2020, 5:38 PM
    Why is the mutableStateOf not wrapped by remember { } automatically? Having to write remember everywhere is just ugly and creates alot of noise
    t
    r
    +3
    • 6
    • 23
  • j

    Julius Marozas

    09/05/2020, 6:08 PM
    In
    Text
    , is there a way to specify the minimum text width in terms of
    em
    ? I have a composable that displays a number and an icon. I want the icon to not move when the amount of digits in the number changes. The maximum amount of digits is 3, so I would like to somehow specify the width of
    Text
    to be
    3 em
    .
    ➕ 1
    t
    v
    +2
    • 5
    • 6
  • v

    vipulasri

    09/06/2020, 7:54 AM
    I am trying to replicate the Instagram like button animation, little confused how to proceed with compose animations. I can use ObjectAnimator if I had to implement it in a traditional way. Can anybody guide me on this?
    d
    • 2
    • 1
  • a

    Artem Kopan

    09/06/2020, 9:51 AM
    How to check if value was changed by user or not in Slider? I need to handle start and end event
    t
    • 2
    • 5
Powered by Linen
Title
a

Artem Kopan

09/06/2020, 9:51 AM
How to check if value was changed by user or not in Slider? I need to handle start and end event
t

Timo Drick

09/06/2020, 10:20 AM
Not sure if i understood the question correct. But the onValueChange callback will tell you that the user changed the slider position. There is also a onValueChangeEnd callback.
a

Artem Kopan

09/06/2020, 11:25 AM
I wanna make something like seekbar. As I understood, the analog of seekbar is Slider. It will be nice to understand how to handle onValueChange from user actions. I’m trying to implement media player and there are two sources of slider value: from the player or from the user (while seeking)
t

Timo Drick

09/06/2020, 11:27 AM
You need to use a state variable for the value. Maybe have a look in the documentation: https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary#Slider(kotlin.Float,%20kotlin.Function1,%20androidx.compose.ui.Modifier,%20kotlin.ranges.ClosedFloatingPointRange,%20kotlin.Int,%20kotlin.Function0,%20androidx.compose.ui.graphics.Color,%20androidx.compose.ui.graphics.Color,%20androidx.compose.ui.graphics.Color,%20androidx.compose.ui.graphics.Color,%20androidx.compose.ui.graphics.Color)
I would recommend to update just the state variable in the onValueChange callback. And when you get the onValueChangeEnd callback you seek your player to the correct position. Also you need to update the state when your players position changed. (Hmm yea i think now i understand why you need to get the on start also)
So maybe you have to implement a state on your own to keep track if the user is sliding. You could set this state variable to true on the onValueChange callback and to false in the onValueChangeEnd event. Than you know if you should update the slider position according to the player position
View count: 5