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

    andylamax

    06/17/2020, 12:43 PM
    Upgraded to Canaray 4.2 and Android Studio says plugin is incompatible. Where do I the relase notes for gradle plugin
    4.2.0-alpha01
    ?
    • 1
    • 1
  • a

    Artur Matsehor

    06/17/2020, 9:29 PM
    Hey! I've got a simple form of two fields. Now I want to assign an IME action for a first one, so it will show an arrow on a soft keyboard, which will move focus to a second field. I tried doing this, but it doesn't work for unknown reason, email field stays focused
    z
    • 2
    • 7
  • b

    bohregard

    06/17/2020, 10:45 PM
    So after reading through the slack regarding AnnotatedString, I have some questions 1. I know text composables can be clickable, but is it possible to have portions of the text clickable (ie for resolving links et cetera)? 2. Is it possible to expose the styles with their ranges on the AnnotatedString builder? I ask because if I’m building a string and I replace part of the string but I had already applied a style, the style does not shift with the removal of text (which is fine and makes sense that it wouldn’t). But it would be helpful to have access to the styles that have been appended up to this point to either remove them or offset them by the newly formatted string. (Say because I’m going through a set of rules and formatting text based on these rules)
    z
    s
    • 3
    • 12
  • z

    Zach Klippenstein (he/him) [MOD]

    06/17/2020, 11:23 PM
    Woah… https://twitter.com/intelligibabble/status/1273339533891788800?s=19
    🤯 7
    m
    a
    +3
    • 6
    • 6
  • g

    Guy Bieber

    06/18/2020, 3:01 AM
    Is there an a way to get Clickable to keep incrementing a value while the user presses and then stop on release? Or is there another compose function for that? I have a temp control with two arrow keys and want the temp to increase until they release the key.
    z
    • 2
    • 1
  • e

    Elias

    06/18/2020, 8:13 AM
    Hi there, we are trying to make a floatingActionButton to open a dialog on click. But as the onclick function is not annotated with @Compose, this does not seem to be possible. Does anyone know about the recommended approach to achieve this behaviour?
    a
    z
    • 3
    • 8
  • s

    Santhosh Kumar

    06/18/2020, 11:32 AM
    How can we create a grid list recyclerview adapter? I couldn't find any properties on top of modifiers. As of now AdapterList supports a linear vertical scrolling.
    a
    v
    t
    • 4
    • 3
  • j

    Javier

    06/18/2020, 11:33 AM
    Is there a collapsing toolbar in compose?
    ➕ 1
    a
    • 2
    • 2
  • b

    bohregard

    06/18/2020, 1:20 PM
    I have this small piece of code:
    setContent {
                AppState.currentScreen = Screen.LoadingScreen
    
                Log.d(TAG, "set content")
                MaterialTheme(colors = darkColorPalette()) {
                    Log.d(TAG, "Material Theme")
                    Providers(MainActivityAmbient provides this, DiAmbient provides di) {
                        Log.d(TAG, "Providers")
                        Crossfade(AppState.currentScreen) {
                            Log.d(TAG, "Crossfade $AppState")
                            Log.d(TAG, "Crossfade ${AppState.currentScreen}")
    but the crossfade is called twice If I try to change the currentScreen in the crossfade, I end up in a loop that never ends. How is one supposed to use Crossfade?
    a
    a
    • 3
    • 12
  • m

    Merhawifissehaye

    06/18/2020, 2:22 PM
    How do I create OutlineTextField instead of a FilledTextField
    m
    v
    s
    • 4
    • 7
  • a

    Adrian Blanco

    06/18/2020, 2:34 PM
    I have some trouble keeping scroll state in VerticalScroller. I have a feed screen and a details screen, and when backing from detail to feed the scroll state in feed is reset. I think this used to work fine for me in dev09 or something, anyone has had similar issues?
    • 1
    • 1
  • a

    Ahmed Elhanafy

    06/18/2020, 8:02 PM
    Hello folks, I was wondering if Jetpack compose has a GeometryReader alternative, or any other way of measuring a node's absolute position
    z
    • 2
    • 5
  • g

    Guy Bieber

    06/18/2020, 10:53 PM
    Is the movement from @Model causing a bunch of rework for others? I basically have a Component Interface that has the main @Compose view() function. At construction the components get the part of the app model state they understand injected at construction time. The app model contains the whole state for the application. Right now this is a series of classes and data classes that are @Model. I think I can a similar approach by changing all the model classes to be a ton of mutableStates (seems pretty messy). Are there any restrictions on the types that can be MutableStates? @Model had limitations for arrays, lists (ModelList), and maps (ModelMap)?
    h
    • 2
    • 2
  • a

    Ahmed Elhanafy

    06/19/2020, 1:37 AM
    Hey folks anyway to draw a stroke around Box composable?
    g
    • 2
    • 2
  • a

    Ahmed Elhanafy

    06/19/2020, 2:15 AM
    Can I launch coroutines from compose functions?
    l
    • 2
    • 1
  • t

    Tristan

    06/19/2020, 3:54 AM
    Hello, from this tweet https://twitter.com/intelligibabble/status/1273659190406295553?s=21 what is the difference between by mutableStateOf and by state ? It seems that both are mutable on this example :O
    l
    z
    m
    • 4
    • 5
  • a

    Ahmed Elhanafy

    06/19/2020, 1:32 PM
    Hey folks, I was wondering, is there a way to implement
    flexWrap: wrap
    with the
    Row
    composable?
    z
    • 2
    • 1
  • r

    rophuine

    06/19/2020, 1:47 PM
    One of the most painful UX issues to get right (for me at least, maybe it's just because I'm bad at building mobile apps!) is making sure my layout reacts to whether the keyboard is visible or not. In React Native we have the KeyboardAvoidingView (which works, kind of, if you poke it just right). Is there anything similar for Compose yet? If not, has anyone found a good solution for building a layout which resizes based on whether the keyboard is visible or not? My use-case is basically a chat-style interface: I'm trying to build a chat history (inside a
    VerticalScroller
    ) which takes up most of the screen, with a
    Column
    wrapping the
    VerticalScroller
    and a
    TextField
    element below it, but have the whole thing take up the entire view port that isn't covered by the keyboard (e.g. if the keyboard is hidden, it'll take up the whole height - if the keyboard is shown, it'll reduce in height to take up all the available height except what the keyboard is covering).
    g
    a
    +2
    • 5
    • 6
  • r

    rophuine

    06/19/2020, 1:49 PM
    On another note, the
    AnnotatedString.Builder
    class was really nice - the API was a perfect match for what I was trying to achieve.
    pop(index: Int)
    was particularly useful and really cut down the code I needed to write for my specific use-case.
    🎉 1
    s
    • 2
    • 1
  • a

    Ahmed Elhanafy

    06/19/2020, 2:24 PM
    Folks is there a way to disable these selection controls when long pressing on
    Text
    composable?
    a
    s
    g
    • 4
    • 25
  • s

    Slackbot

    06/19/2020, 4:15 PM
    This message was deleted.
    j
    g
    • 3
    • 2
  • r

    romainguy

    06/19/2020, 7:00 PM
    Apply a blur?
    g
    s
    g
    • 4
    • 10
  • e

    enighma

    06/20/2020, 6:32 AM
    Is there an equivalent of an autosizing textview in compose?
    g
    f
    • 3
    • 3
  • m

    Merhawifissehaye

    06/20/2020, 8:49 PM
    While using view model with jetpack compose, I am trying to update the viewmodel from a button inside the view. I want the state of the composable to be updated from outside it inside the fragment. Below is the gist of what I tried to do. How can I update the composable on an event on a button inside it, however from an action outside of the composable? https://gist.github.com/mfissehaye/0761d3c91da5b355c57438a13021046e
    l
    • 2
    • 3
  • a

    allan.conda

    06/20/2020, 9:10 PM
    In my project Android Studio 4.2C2 can’t resolve to Component.setContent because of AppCompatActivity. I digged and AS is weirdly referring to fragment 1.0.0 instead of at least 1.1.0. This runs fine however so it means it’s probably just an IDE error. I checked the dependency graph and it seems all Fragment should use the latest version 1.0.0 -> 1.2.4 Now I don’t know if it’s an AS Preview, Gradler, or Compose issue. Looking for workarounds and some explanation here…
    i
    a
    • 3
    • 5
  • z

    zalewski.se

    06/21/2020, 2:18 PM
    Is it possible to attach the
    TextField
    to the right side of the screen? I’m trying to use
    ConstraintLayout
    for this, where everything looks as expected with
    Text
    element, but when I changed it to
    TextField
    it looks like the:
    right constrainTo parent.right
    doesn’t work 🤔 To give you some code: This is sample with `Text`:
    ConstraintLayout(
                modifier = Modifier.fillMaxWidth().wrapContentHeight(),
                constraintSet = ConstraintSet {
                    tag("amountTag").apply {
                        right constrainTo parent.right
                        right.margin = 16.dp
                        horizontalBias = 1.0f
                        centerVertically()
                    }
                }
        ) {
            Text(
                    modifier = Modifier.tag("amountTag"),
                    fontSize = 16.sp,
                    text = rate.value.toString()
            )
        }
    And when I just changed
    Text
    to `TextField`:
    TextField(
                    modifier = Modifier.tag("amountTag"),
                    value = value,
                    onValueChange = {
                        value = it
                    }
            )
    Also I tried to add some modifiers to
    TextField
    like:
    .wrapContentWidth(Alignment.End)
    but same result.
    a
    • 2
    • 2
  • a

    andylamax

    06/21/2020, 2:36 PM
    Why do need to call
    setContent(Recomposer.current()) {}
    in fragments? and if we must pass a Recomposer as a parameter, in which scenario would I need to pass another Recomposer? say
    setContent(Recomposer.new()){}
    . If not, why is
    Recomposer.current()
    not a default parameter value in
    setContent
    ?
    a
    • 2
    • 10
  • h

    henrikhorbovyi

    06/22/2020, 3:17 PM
    Hey everyone... I'm trying to change the size of a drawable but it does not work 🤔 I'm trying >>>
    Image(
         asset = vectorResource(id = R.drawable.ic_android),
         modifier = Modifier.size(56.dp),
         colorFilter = ColorFilter.tint(Color.Red)
    )
    s
    v
    +2
    • 5
    • 10
  • l

    Lilly

    06/22/2020, 9:10 PM
    Is there an equivalent to loading spinner/ indicator? I would like to show a laoding indicator while a heavy task is running. Maybe something with a dimmed background like it's done with a dialog to prevent user input or something similar.
    j
    a
    • 3
    • 4
  • a

    andbapps

    06/22/2020, 9:56 PM
    I'm trying to animate things using a transition as following, but it snaps between the two endpoints immediately without animating any of the intermediate values. Is there something about this that I'm missing?
    @Composable
    fun TestAnimation() {
        val moved = state { false }
        val offset = DpPropKey()
        val transition = transitionDefinition<Boolean> {
            state(true) {
                this[offset] = 100.dp
            }
            state(false) {
                this[offset] = 0.dp
            }
            transition {
                offset using tween {
                    easing = LinearEasing
                    duration = 1000
                }
            }
        }
        Transition(definition = transition, toState = moved.value) { transitionState ->
            println("transitionState[offset] = ${transitionState[offset]}")
            Box(
                modifier = Modifier
                    .clickable(onClick = { moved.value = !moved.value })
                    .padding(start = transitionState[offset])
                    .size(56.dp),
                shape = CircleShape,
                backgroundColor = Color.Blue
            )
        }
    }
    z
    a
    • 3
    • 4
Powered by Linen
Title
a

andbapps

06/22/2020, 9:56 PM
I'm trying to animate things using a transition as following, but it snaps between the two endpoints immediately without animating any of the intermediate values. Is there something about this that I'm missing?
@Composable
fun TestAnimation() {
    val moved = state { false }
    val offset = DpPropKey()
    val transition = transitionDefinition<Boolean> {
        state(true) {
            this[offset] = 100.dp
        }
        state(false) {
            this[offset] = 0.dp
        }
        transition {
            offset using tween {
                easing = LinearEasing
                duration = 1000
            }
        }
    }
    Transition(definition = transition, toState = moved.value) { transitionState ->
        println("transitionState[offset] = ${transitionState[offset]}")
        Box(
            modifier = Modifier
                .clickable(onClick = { moved.value = !moved.value })
                .padding(start = transitionState[offset])
                .size(56.dp),
            shape = CircleShape,
            backgroundColor = Color.Blue
        )
    }
}
z

Zach Klippenstein (he/him) [MOD]

06/22/2020, 10:02 PM
I'm not sure if this is the only problem, but you are creating a new
offset
key every time
TestAnimation
is invoked. Either
remember
it or declare as a top-level val.
a

andbapps

06/22/2020, 11:23 PM
Unfortunately that doesn't fix the issue but that's a good point
a

Andrey Kulikov

06/22/2020, 11:31 PM
you need to do the same with transitionDefinition. wrap it into remember
a

andbapps

06/23/2020, 12:13 AM
Thank you, implementing both of those worked!
View count: 1