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

    Lilly

    03/09/2021, 2:34 AM
    I would like to preview an
    AnimatedVisibility
    composable but the animation inspector does not appear. Is that intended behavior? What are the requirements so that animation inspector is available?
    d
    • 2
    • 2
  • c

    chris

    03/09/2021, 3:07 AM
    Given some type of container how would I draw only the bottom half of a piece of text within the given container? Such that the top of the half of text (aka the middle vertical point if the text was fully drawn) touches the top of the parent container and the bottom touches the bottom of the parent container?
    n
    a
    • 3
    • 4
  • l

    Law Gimenez

    03/09/2021, 3:53 AM
    Hi guys! I want to update the Arctic Fox build but was greeted with this error instead. Anyone encountered this?
    i
    • 2
    • 6
  • d

    Deepak Gahlot

    03/09/2021, 4:35 AM
    Anyone Knows a good sample about implementing BottomSheet in Jetpack Compose
    j
    • 2
    • 1
  • s

    Shivam Sethi

    03/09/2021, 4:38 AM
    Let's say a composable is about to enter/added to the tree how can I animate it's enter transition ? Is there something similar to .transition modifier like swiftUI ?
    d
    s
    • 3
    • 22
  • j

    Jason Ankers

    03/09/2021, 4:46 AM
    Is it possible to opt a
    LazyColumn
    out of a nested scroll chain? The docs only explain how to opt in/configure the existing chain: https://developer.android.com/jetpack/compose/gestures#auto-nested-scrolling
    m
    • 2
    • 9
  • a

    Alan Yin

    03/09/2021, 6:46 AM
    How to implement on screen keyboard with Compose?
    j
    c
    z
    • 4
    • 9
  • r

    Rajashekar

    03/09/2021, 6:57 AM
    I trying to animate the changes between points which I have drawn in canvas, check output preview inside thread.
    val points: List<Offset> = listOf(
        Offset(200f, 200f), Offset(400f, 200f),
        Offset(200f, 200f), Offset(200f, 400f),
        Offset(400f, 200f), Offset(400f, 400f),
        Offset(200f, 400f), Offset(400f, 400f),
        Offset(200f, 400f), Offset(200f, 600f),
        Offset(200f, 600f), Offset(400f, 600f),
        Offset(400f, 400f), Offset(400f, 600f),
    )
    Two offsets completes a line, this whole points makes -> 8 How I want is, lines must be drawn between those points at certain duration.
    Canvas(
        modifier = Modifier.fillMaxSize()
    ) {
        drawPoints(
            points = points,
            pointMode = PointMode.Lines,
            color = Color.Gray,
            strokeWidth = 16f,
            cap = StrokeCap.Round,
            pathEffect = PathEffect.dashPathEffect(floatArrayOf(8f, 16f))
        )
    }
    d
    • 2
    • 8
  • s

    Shivam Sethi

    03/09/2021, 7:22 AM
    How can I make text word to go to bottom if it overflows the container space, I see clip and ellipse options
    👀 1
    u
    • 2
    • 1
  • a

    Ahmet Delibaş

    03/09/2021, 8:10 AM
    Hello everyone. I want to use a dialog, for this I'm using AlertDialog from compose.material. I want to fill max width, but I couldn't find a way to do it. Do you know a way?
    u
    • 2
    • 6
  • u

    Utkarsh Tiwari

    03/09/2021, 9:15 AM
    Hi folks, I am not sure who is the right person to consult regarding this. I am playing around with the code from the official documentation of
    ModalBottomSheetLayout
    and it seems like the scrim to dismiss the modal is being triggered when tapping an area within the sheet. Is this expected behaviour? Here is my code
    scrim bug.mp4
    p
    j
    m
    • 4
    • 9
  • l

    loloof64

    03/09/2021, 9:32 AM
    Hi ! I am trying to launch a preview on my phone, but I am getting an error
    androidx.compose.ui.tooling.preview.PreviewActivity is not an Activity subclass or alias
    though I managed to launch it yesterday. This is my preview :
    @Preview
    @Composable
    fun ChessBoardPreview() {
        ChessBoard(size = 60.dp)
    }
    where ChessBoard is a Composable component that I'm writing
    Android Studio Arctic Fox | 2020.3.1 Canary 8
    Build #AI-203.7148.57.2031.7165533, built on February 23, 2021
    Runtime version: 11.0.8+0-b944-P17168821 amd64
    VM: OpenJDK 64-Bit Server VM by N/A
    Linux 5.10.19-200.fc33.x86_64
    GC: G1 Young Generation, G1 Old Generation
    Memory: 1280M
    Cores: 4
    Registry: external.system.auto.import.disabled=true
    Non-Bundled Plugins: org.intellij.plugins.markdown
    Current Desktop: GNOME
    • 1
    • 1
  • y

    yousefa2

    03/09/2021, 9:56 AM
    Came across a curious situation with AndroidView this morning. I have composable that renders a list of
    AndroidView
    . The
    View
    used for
    AndroidView
    is provided by a generic provider that takes in some input and outputs a
    View
    type.
    @Composable
    fun BasketItemsList(
        modifier: Modifier,
        basketItems: List<ProductState>,
        provider: ProductCard,
        interactionListener: ProductCardView.InteractionListener
    ) {
        LazyColumn(modifier = modifier) {
            items(basketItems) { product ->
                AndroidView(factory = { provider.view }) {
                    Timber.tag("BasketItemsList").v(product.toString())
                    provider.setup(product, interactionListener)
                }
            }
        }
    }
    With this sample, any interaction with the ProductCard view’s doesn’t update the screen. Logging shows that the state gets updated but the catch is that it’s only updated once per button. For example, I have a favourites button. Clicking it once pushes a state update only once, any subsequent clicks doesn’t propagate. Also the card itself doesn’t updates. It’s as if it was never clicked. Now changing the block of
    AndroidView.update
    to cast from the
    ProductCard
    interface to a concrete view type works as expected. All clicks propagate correctly and the card view gets updated to reflect the state.
    @Composable
    fun BasketItemsList(
        modifier: Modifier,
        basketItems: List<ProductState>,
        provider: ProductCard,
        interactionListener: ProductCardView.InteractionListener
    ) {
        LazyColumn(modifier = modifier) {
            items(basketItems) { product ->
                AndroidView(factory = { provider.view }) {
                    Timber.tag("BasketItemsList").v(product.toString())
    //                provider.setup(product, interactionListener)
                    (it as ProductCardView).setup(product, interactionListener)
                }
            }
        }
    }
    What am I missing here? why does using
    ProductCard
    type not working while casting the view to it’s type is working?
    z
    • 2
    • 6
  • d

    Deepak Gahlot

    03/09/2021, 9:57 AM
    How can we store the state of the LazyColumn. I read something about rememberSaveableStateHolder(), will that help. ?
    a
    p
    t
    • 4
    • 12
  • k

    Karthick

    03/09/2021, 10:13 AM
    can we use mutableState from ViewModel or we must need to use LiveData and use livedata.observeAsState()
    t
    • 2
    • 1
  • l

    loloof64

    03/09/2021, 11:02 AM
    Reading https://developer.android.com/jetpack/compose/gestures#dragging, and https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/PointerInputScope: I 'm looking for a way to handle mouse release, but I did not manage : which function can help me handle mouse release ?
    • 1
    • 1
  • f

    Filip Wiesner

    03/09/2021, 11:19 AM
    How to properly chain animate*AsState? Animations down the "chain" don't get triggered as easily. I have the following code:
    val ballSpacing = remember { Offset(0f, 48f * density) }
    var ball1 by remember { mutableStateOf(Offset.Zero) }
    val ball2 by animateOffsetAsState(ball1 + ballSpacing)
    val ball3 by animateOffsetAsState(ball2 + ballSpacing)
    I move ball1 with gestures and I want the other balls to follow. I must move the ball really slowly to trigger the animations but when it starts working it's smooth so long as I don't stop moving them (GIF in thread)
    d
    • 2
    • 15
  • a

    alexsullivan114

    03/09/2021, 12:40 PM
    I have a scenario I'm not sure how to progress with. I have a composable that either animates on every "tick" or is scrollable by the user. I'm using the
    translationY
    value for both the scrolling and the tick. Right now, when I toggle between scrolling mode or ticking animation mode the composable kind of swaps between the two different translationY values. I'd like to remember the old translationY and increment from there but I'm not sure how to make that happen...I've added the relevant code to this thread.
    f
    d
    • 3
    • 10
  • l

    Lilly

    03/09/2021, 1:37 PM
    I have made a slidable composable whicht sits under the top app bar but unfortunately the composable does not slide under the top app bar but instead over it. Here the code:
    Scaffold(
        topBar = {
    		Column {
    			TopAppBar(
    				...
    			)
    			AnimatedVisibility(
    				visible = (connectionState == BluetoothConnectionState.Disconnected),
    				enter = slideInVertically(),
    				exit = slideOutVertically(targetOffsetY = { value -> -value }),
    				content = { ConnectionStatusBannerComponent(onAction = { }) }
    			)
    		}
    	},
    )
    Does someone have an idea?
    f
    j
    • 3
    • 6
  • s

    Se7eN

    03/09/2021, 2:06 PM
    Why isn't there a
    cutoutShape
    for
    BottomNavigation
    ?
    l
    • 2
    • 1
  • b

    Bradleycorn

    03/09/2021, 2:40 PM
    hmmm ... I have a somewhat weird issue ... I have setup the manifest for my app to handle orientation changes myself:
    android:configChanges="orientation|screenSize"
    When I run my app, everything works as expected ... when I rotate the device the activity does not get re-created, and my main
    setContent
    composable gets recomposed. But ... if I rotate the device "upside down", the composable does NOT get recomposed? What am I missing? To be clear .. the device (a phone) starts in a "normal" portrait orientation ... i rotate it 90 degrees to a landscape orientatin and my root composable gets recomposed. Great. I rotate 90 degrees again to portrait (but now upside down, with the earpiece at the bottom and the mic at the top), and my root composable does NOT get recomposed and the display is now "sideways"?
    t
    i
    • 3
    • 6
  • o

    Orhan Tozan

    03/09/2021, 2:47 PM
    Why does the inner column not fill the whole screen? Code below results in whole screen being blue, but only a little bit red (height of the text). I would expect the inner column to fill the whole screen (and thus make the whole screen red).
    Column(modifier = Modifier.fillMaxHeight().background(Color.Blue)) {
        Column(modifier = Modififer.fillMaxHeight().background(Color.Red)) {
            Text("Hi")
        }
    }
    t
    a
    • 3
    • 6
  • s

    Stylianos Gakis

    03/09/2021, 3:10 PM
    With animations. Is there a way to combine
    updateTransition
    with
    keyframes
    or something similar to have more control over one value? To exmplain: I want an animation that will fluidly animate rotation simply done with transition.animateFloat. But I want the color to be White from 0-50% of the animation and then immediately change to Red at 50% and stay like that for 50-100% of the animation. Any ideas?
    d
    • 2
    • 5
  • m

    martinsumera

    03/09/2021, 3:30 PM
    I’m looking at SideEffect explanation on the https://developer.android.com/jetpack/compose/lifecycle but I don’t really understand why and when should I use it. Can somebody explain me what is the difference between the following:
    val backCallback = remember { /* ... */ }
    SideEffect {
        backCallback.isEnabled = enabled
    }
    
    and
    
    val backCallback = remember { /* ... */ }
    backCallback.isEnabled = enabled
    a
    • 2
    • 4
  • j

    Joseph D

    03/09/2021, 3:58 PM
    I've seen there's no API for reading for example a Modifier's size, what's the reason behind that? Let's say I need to read it because some other value depends on it.
    a
    s
    s
    • 4
    • 9
  • c

    Colton Idle

    03/09/2021, 4:20 PM
    I have a
    Red
    composable and
    Blue
    composable that I want to overlap by 35%. The three ways I've thought about doing this is: 1. Have these two in a
    Box
    , but apply a padding to the top of blue composable that I calculate somehow to be 35% of bottom of red 2. Have these two in a Column, and someone apply a negative padding to a value that I calculate somehow to be 35% of the bottom of red 3. Write a custom layout? (seems scary even though this is supposed to be a lot easier in compose) Anyone have other ideas or an idea of how I would go about this? Right now I just hard coded the padding and it works, but the height of the red square will change and so the hard coded padding idea will fall apart. Edit: Wish there was a way to shrink the preview size in slack. Sorry
    l
    b
    a
    • 4
    • 18
  • r

    Rabindra Khadka

    03/09/2021, 5:53 PM
    Hello Everyone .How to add blur effect ?
    f
    • 2
    • 3
  • c

    Colton Idle

    03/09/2021, 7:10 PM
    Does material compose provide toggle buttons I can use? I'm building a text editor and being able to do center, left, right with something like this component in material guidelines makes a lot of sense. https://material.io/components/buttons#toggle-button I looked here and didn't see them mentioned: https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary#icontogglebutton
    r
    • 2
    • 1
  • b

    Bradleycorn

    03/09/2021, 7:32 PM
    Building this in the old view system was NOT fun, and involved writing a custom LayoutManager for the main recycler view, and using some wild stuff to link 3 recycler views together (main view, one for the row header, and one for the column header) and keep their scrolls/flings in sync. I haven't tried it yet, but I wonder how much easier this will be in Compose?
    untitled.webm
    ➕ 2
    t
    c
    +5
    • 8
    • 18
  • b

    Bryan Herbst

    03/09/2021, 7:33 PM
    Is there any high level guidance for defining vector drawables in a Compose world? Material defines them as paths in Kotlin files, but we of course still have the ability to define them as vector drawable resources. I’m assuming there’s at least some performance gain in defining them in Kotlin as paths and doing so also enables multiplatform support, but is there a meaningful benefit for an Android-only application?
    t
    n
    • 3
    • 7
Powered by Linen
Title
b

Bryan Herbst

03/09/2021, 7:33 PM
Is there any high level guidance for defining vector drawables in a Compose world? Material defines them as paths in Kotlin files, but we of course still have the ability to define them as vector drawable resources. I’m assuming there’s at least some performance gain in defining them in Kotlin as paths and doing so also enables multiplatform support, but is there a meaningful benefit for an Android-only application?
t

tad

03/09/2021, 7:54 PM
It will save you some miniscule amount of time in aapt, and some runtime costs for converting those resources into ImageVector objects.
n

Nader Jawad

03/09/2021, 7:54 PM
Compose's vector graphics APIs are more generic and decouple the serialization from the rendering. This differs from VectorDrawable in the fact the parsing from the compiled xml format and drawing are coupled together.
💯 2
We have some sample source that shows how to create vector graphics dynamically here: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/VectorGraphicsDemo.kt;l=44?q=VectorGraphicsDemo&amp;sq=
t

tad

03/09/2021, 7:56 PM
I actually repurposed the material generator code in our Gradle build to convert some FontAwesome icons, I should make that a plugin
You basically drop SVGs in
src/main/icons
and get generated Kotlin
b

Bryan Herbst

03/09/2021, 7:58 PM
Thanks! Would love to see an SVG -> ImageVector built into Studio as well alongside the existing SVG -> Vector drawable
👍 2
I’ll take a peek at Material’s because I’d love to have that automated using our icon library
View count: 3