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

    Noé Casas

    03/18/2021, 10:37 AM
    There are two bugs related to
    Result
    affecting 1.4.31, which is needed by compose beta: • https://youtrack.jetbrains.com/issue/KT-44867 • https://youtrack.jetbrains.com/issue/KT-45259 These problems result in a
    ClassCastException
    and the subsequent app crash. Is there any workaround? How are people using compose dealing with this?
    t
    t
    • 3
    • 15
  • s

    Shakil Karim

    03/18/2021, 11:08 AM
    Finally https://github.com/google/accompanist/pull/259 🎉
    🎉 2
    l
    • 2
    • 1
  • c

    Colton Idle

    03/18/2021, 11:13 AM
    What's the preferred way to create the expand/collapse effect on a row item? I think I saw Chris Banes do this on twitter once (months ago) but I can't find it. It looks like there are two ways to do this. 1. On the root composable you can call the
    .animateContentSize()
    modifier 2. Have the expandable content wrapped in
    AnimatedVisibility {}
    composable At runtime the behavior of
    AnimatedVisibility
    looks slightly better I think? Code examples of each in thread.
    t
    d
    • 3
    • 4
  • m

    Mikołaj Kąkol

    03/18/2021, 11:46 AM
    hi, is there way to set gravity in TextField?
    f
    • 2
    • 2
  • f

    Francois Morvillier

    03/18/2021, 2:14 PM
    Using MutableState, MutableStateFlow or MutableLiveData (are there others?) in a @Composable function will automatically trigger recomposition when the underlying data changes. Say I have my own DataHolder to some data (a graph) and that my DataHolder receives notifications when the underlying graph data changes. It also notifies whoever is observing it. Is there a way to use my DataHolder in @Composable functions in the same way we would use MutableState so that it will trigger recomposition? For example implementing the State<T> interface?
    a
    • 2
    • 7
  • s

    Samir Basnet

    03/18/2021, 2:28 PM
    ClickableText(
        modifier = Modifier
            .align(Alignment.CenterHorizontally)
            .padding(top = 10.dp)
            .indication(
                interactionSource = remember { MutableInteractionSource() },
                indication = rememberRipple(true)
            ),
        text = noAccount,
        style = MaterialTheme.typography.subtitle2
    ) {
        Timber.d("$it")
    }
    How to add ripple in ClickableText?Above code did not work.Am i doing it wrong?
    z
    • 2
    • 1
  • d

    Deepak Gahlot

    03/18/2021, 3:18 PM
    Hi All, what will be the best approach to build a similar UI shown in the video below. I'm confused if i should write a custom ViewPager, or I should use Navigation in compose to build this. Or there is something else which can be used
    master-data.mov
    :android-wave: 2
    m
    i
    +2
    • 5
    • 7
  • n

    Neal Sanche

    03/18/2021, 4:13 PM
    Hi All! I've been given a design to implement in Compose that has a primary colour that doesn't contrast much with the desired surface colour and background colour. So, TextButton content ends up nearly invisible since the primary colour is chosen as the default content colour for the text. I could make text buttons use the secondary colour like this:
    TextButton(
                    colors = textButtonColors(contentColor = MaterialTheme.colors.secondary),
                    onClick = {
                    }
                ) {
                    Text("To Step 2")
                }
    But I'd like to have something like this globally. Is there a way to provide the correct colour in my theme?
    l
    c
    • 3
    • 6
  • n

    Nat Strangerweather

    03/18/2021, 4:54 PM
    Is this the correct way of using text on a canvas in Compose? :thread-please:
    d
    • 2
    • 4
  • v

    Vinay Gaba

    03/18/2021, 6:22 PM
    Showkase has been updated to use
    beta-02
    . For the folks who are new here, Showkase is Airbnb’s library that auto generates an UI component browser for your Compose UI elements. More details in this thread I previously shared - https://kotlinlang.slack.com/archives/CJLTWPH7S/p1598635176423700
    🤩 2
    🎉 13
    🚀 2
    👍🏽 1
    m
    • 2
    • 1
  • r

    Rick Regan

    03/18/2021, 7:54 PM
    In this code example using
    Crossfade
    (see thread), when I click "Reset", the
    Button
    labelled "Button" fades and goes back to full color. I don't know what that animation is, or why it's animating anything at all.
    d
    • 2
    • 11
  • c

    Chris Grigg

    03/18/2021, 8:58 PM
    Hey folks, I believe I just found a bug involving a
    Box
    with
    scale
    set to 0f and content with an
    onClick
    handler. When scale is 0f, the content’s
    onClick
    handler will be applied to the whole window. Reproducible code coming below, replying to myself.
    z
    • 2
    • 5
  • n

    Neal Sanche

    03/18/2021, 9:37 PM
    This afternoon I've been trying to get an animation to run as follows: when some state, call it
    isVisible
    is false, animate the alpha of a component infinitely between zero and one. If
    isVisible
    is true, animate the current alpha up to 1.0f. Code in thread.
    d
    • 2
    • 13
  • o

    Olivier Patry

    03/18/2021, 10:18 PM
    I published a small
    GridLayer.kt
    gist for those who could be interested. It aims at displaying a (configurable) grid to ease alignment when implementing design mockups (defaults to
    8.dp
    and red color). https://gist.github.com/opatry/fde12d9a5c52179338613278d901eacb
    💡 4
    a
    • 2
    • 6
  • t

    Tim Malseed

    03/19/2021, 12:39 AM
    I'm using
    ViewModel
    as a state container for a Composable screen. The
    ViewModel
    is scoped to the nav graph via
    @HiltViewModel
    & `hiltNavGraphViewModel()`` . It seems that this pattern does not support assisted injection into the
    ViewModel
    , so I have to pass initial state to the screen's Compose function, and then pass that state into the
    ViewModel
    . This feels a bit uncomfortable. Am I approaching this the wrong way?
    i
    • 2
    • 8
  • k

    Kshitij Patil

    03/19/2021, 10:12 AM
    Earlier, with
    onImeActionPerformed
    argument to TextField, I had a chance to implement some global logic for all the actions. Like I had written if the action was
    Done
    , hide the software keyboard and it was possible to do so because of the handy
    softwareKeyboardController
    argument to
    onImeActionPerformed
    . How can I do the same using KeyboardActions now? The callback methods are not “Composables” so I won't even be able to use
    LocalSoftwareKeyboardController.current
    a
    • 2
    • 4
  • p

    Pedro Ruiz

    03/19/2021, 10:54 AM
    Hi, I'm trying to change OutlinedTextfield's background color, but It's not applying. Anybody knows why?
    OutlinedTextField(
        value ="", 
        onValueChange = { /*TODO*/ },
        colors = TextFieldDefaults.outlinedTextFieldColors(backgroundColor = Color.White)
    )
    r
    • 2
    • 1
  • a

    Arun

    03/19/2021, 11:41 AM
    I was just exploring on Compose navigation. So, we have the following for scoping ViewModel to the destination.
    val exampleViewModel = hiltNavGraphViewModel<ExampleViewModel>()
    However, I couldn’t find anything or any info on passing a
    ViewModelProvider.Factory
    above (in case there are parameters for the ViewModel constructor). Am I missing something or is it yet to be developed?
    l
    g
    +2
    • 5
    • 12
  • k

    Kshitij Patil

    03/19/2021, 12:50 PM
    How to use
    rememberSaveable
    for
    TextFieldValue
    ?
    a
    • 2
    • 2
  • c

    Chris Grigg

    03/19/2021, 3:29 PM
    Hey folks! I’m using ExoPlayer in Compose with
    AndroidView
    and I need to set a layout attribute as described at https://exoplayer.dev/ui-components.html#choosing-a-surface-type. I’m having trouble finding how I should do this. Could someone point me in the right direction? I’m going to add a small code snippet in a reply below.
    a
    c
    • 3
    • 35
  • t

    Tlaster

    03/19/2021, 3:32 PM
    I've create a
    Zoomable
    layout for Jetpack Compose that can easily handle zoom in and out with dragging support, hope it can help: https://github.com/Tlaster/Zoomable
    🎉 15
    s
    m
    • 3
    • 2
  • j

    Joe Jensen

    03/19/2021, 4:26 PM
    Hi everyone! I see this in
    SubcomposeLayout.kt
    :
    "Intrinsic measurements are not currently supported by SubcomposeLayout"
    Will intrinsic measurements soon be supported in
    SubcomposeLayout
    ? Or is the intention for it to never support intrinsic measurements?
    a
    s
    • 3
    • 5
  • a

    alorma

    03/19/2021, 4:39 PM
    Hi. I'm using an IconButton to show a
    DropdownMenu
    , how can I test it? at least test that some child is shown, or whole dropdown
    • 1
    • 2
  • c

    Colton Idle

    03/19/2021, 4:59 PM
    Complete animation noob here. Never touched animations in the regular view based system (the only animations entered my app when Lottie became a thing) And now I'm trying to build this little animation. How would I go about creating a fluid arrow like this (that the pixel launcher used to have way back when. I swear that @cbtweeted about this as an AVD a while back but I can't find the tweet. Maybe it was Nick Butcher?). Animated vector drawable in compose? animate*AsState? Lottie?
    d
    a
    a
    • 4
    • 18
  • l

    Lucien Guimaraes

    03/19/2021, 5:23 PM
    Can we update the inner padding of TextField to avoid the text being cropped depending of the TextField height ? I created a custom TextField to looks like a SearchView, but when I'm trying to customize the height, text is heavily cropped. Code in thread
    c
    p
    • 3
    • 6
  • n

    Nat Strangerweather

    03/19/2021, 8:00 PM
    Are there any docs for text on a canvas? I am using
    TextDelegate
    as kindly suggested here to use text on my canvas. But beyond that I am a little lost and would welcome some examples of how to position words precisely, for instance. Googling is not helping much as yet. 😅
    f
    • 2
    • 1
  • j

    Jorkoh

    03/19/2021, 10:53 PM
    Are there Compose Color alternatives for the ColorUtils.blend*() methods? I imagine there's something to support the multiple color animation APIs but I'm not sure where to look
    r
    • 2
    • 4
  • i

    itnoles

    03/20/2021, 1:54 AM
    Would there be material color picker version of Jetpack Compose for theme?
    r
    • 2
    • 1
  • s

    Samir Basnet

    03/20/2021, 6:58 AM
    If anyone have implemented a login api in compose screen with viewModel can you please share a gist. I am a little confused about how to do it properly
    • 1
    • 3
  • c

    chansek

    03/20/2021, 7:24 AM
    What is the alternative for android:maxLength in OutlinedTextField?
    ➕ 2
    c
    n
    • 3
    • 4
Powered by Linen
Title
c

chansek

03/20/2021, 7:24 AM
What is the alternative for android:maxLength in OutlinedTextField?
➕ 2
c

Colton Idle

03/20/2021, 6:42 PM
I tried to do this recently and couldn't find anything in the docs. Only things available were maxLines
n

nglauber

03/21/2021, 1:03 AM
TextField(
    label = { Text("Name") },
    value = nameState,
    onValueChange = { s: String ->
        if (s.length < 50) nameState = s
    }
)
🤷‍♂️
c

Colton Idle

03/21/2021, 8:13 PM
@nglauber it's actually quite nice to see how quick it is to whip something like that up. 😄 I think a part of the material input fields on material.io though shows a character count which would be nice to have out of the box... but this is def nice too.
n

nglauber

03/21/2021, 9:02 PM
I partially agree. Have more features out of the box is a good thing, however it adds more complexity to customize a few things… For instance imagine that you want a different font color if the max length is about to be reached out. How could you do that if this feature is out of the box? btw… it’s also easy to show this char count 😛
val maxLength = 20
Column {
    OutlinedTextField(
        label = { Text("Name") },
        value = nameState,
        onValueChange = { s: String ->
                        if (s.length <= maxLength) {
                            nameState = s
                        }
        }
    )
    Text(
        "${nameState.length} / $maxLength",
        fontSize = 12.sp,
        modifier = Modifier.align(Alignment.End)
    )
}
You can put this in a Composable function an boom! You have a custom TextField 😊
View count: 3