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

    amar_1995

    01/03/2020, 3:53 PM
    How to render Html context in compose ?
    m
    • 2
    • 1
  • b

    Bruno_

    01/06/2020, 10:20 PM
    VerticalScroller no longer has
    onScrolledPositionChanged
    , was it removed on purpose?
    a
    m
    • 3
    • 6
  • i

    Ian Warwick

    01/07/2020, 9:50 AM
    Slightly confused about
    Shape
    who performs the drawing? is there an example? I want to draw an oval shape (not a
    CircleShape
    which is based off
    RoundedCornerShape
    )
    • 1
    • 1
  • g

    gpaligot

    01/08/2020, 2:01 PM
    Hello there! At the Google I/O 2019, in Declarative UI Patterns talk,
    asyncLoad
    function is presented by speakers in one slide (

    https://youtu.be/VsStyq4Lzxo?t=1267▾

    ) but I don’t find this function in the latest artifact or in source code of Jetpack Compose. Someone can tell me if this function has been removed or if it is in development? Thanks in advance! 🙂
    a
    a
    k
    • 4
    • 9
  • a

    Andreas Jost

    01/08/2020, 2:45 PM
    Hi, if I use a Spacer in SwiftUI without a height argument, the spacer takes all available space. Is there an equivalent in Compose? So if I have a Column, that has the following subviews: "HeightSpacer, Text, HeightSpacer, Text, HeightSpacer" the HeightSpacers should equally take the remaining space automatically.
    z
    l
    • 3
    • 4
  • i

    Ian Warwick

    01/08/2020, 9:27 PM
    how to convert
    Dp
    to
    Px
    is there any special helper yet with compose APIs ? 🙂
    z
    m
    • 3
    • 8
  • a

    amar_1995

    01/09/2020, 6:24 AM
    I am trying to make navigation drawer(sidebar) using
    ModelDrawerLayout
    . Now, I have some question regarding implementation. 1. Is there anyway to resize the size of navigation drawer. 2. Is there any way to navigate inside navigation drawer. Here navigate means if I tap on some item(inside navigation drawer) it navigate to sub-item inside navigation drawer. For example, there is setting item inside navigation bar if tap on it will navigate to sub-menu inside same navigation bar.
    m
    • 2
    • 2
  • i

    Ian Warwick

    01/09/2020, 9:14 AM
    Just open-sourced my little playground app memset which will eventually be a memory card creator app (like flash cards) just working on the editor part and at some point will add the ability to persist cards and see them as a listing. I tried to do this before with commercial motivations but failed due to time (got many other hobbies and interests!) so this time round I am going to offer the source code as open so other folks can benefit from my failed projects 😆 https://github.com/fluxtah/memset (apologies no docs yet)
    👍 3
    • 1
    • 1
  • i

    Ibrahim Ali

    01/09/2020, 11:35 AM
    Secure your UI with Jetpack Compose is more easier than before ! https://ibrahimalii.github.io/Securing-UI-With-Jetpack-Compose/
    m
    • 2
    • 2
  • i

    Ian Warwick

    01/09/2020, 2:55 PM
    Not sure what I am doing wrong here but newing up a
    Color
    for Green shows up as Red in
    @Preview
    and in emulator? apologies if this is a known issue
    c
    m
    • 3
    • 8
  • i

    Ian Warwick

    01/09/2020, 10:37 PM
    Hey folks not sure why this is happening, I have a vector that seems to draw over itself depending on how I structure my compose tree, I have two
    @Composable
    s, one
    DrawVectorToggle()
    and another version
    DrawVectorToggleDRY()
    The first one draws a toggle and toggles up and down fine but the second ones vector draws over the first state when toggled, anyone see anything wrong here in usage pattern that could be causing this?
    Untitled
    c
    • 2
    • 5
  • k

    karandeep singh

    01/10/2020, 6:22 AM
    Hi folks, can any one tell me what’s the difference between state and memo wrt to compose?
    z
    i
    • 3
    • 5
  • i

    Ian Warwick

    01/10/2020, 8:43 AM
    Morning folks, is there any way to detect clicks further up the compose tree? I have a child that toggles visibility of a local element, but I want the clicks on the root to cancel (basically a pop up box that when you click outside of the popup it will close it)
    m
    • 2
    • 14
  • m

    Manuel Wrage

    01/10/2020, 10:27 AM
    Can we expect some ambient functions like 'ambientOrNull' or 'ambientOrElse'?
    a
    a
    • 3
    • 15
  • a

    alexsullivan114

    01/10/2020, 2:42 PM
    Tangental but kind of related to the above ambient question - right now the docs for an ambient show an example of, like, getting a current user via an ambient. My gut reaction is that that's putting the wrong stuff into ambients and is better handled by some other caching layer, but I could be off base here. I think I like ambients (a lot) for styling or strings or size paramters and whatnot, and I think I like them a lot less for application logic. A user, for example, could (presumably) be correctly modeled as not existing in an application (before they're logged in for example), and trying to use an ambient for that feels like it sets you up for very surprising crashes at runtime when you realize you re-used some component that's using the user ambient in your logged out state. It's similarly difficult to handle in a default way without dramatically reducing it's utility - if all ambients need a default, you could have an ADT or something representing a logged in vs logged out user, or a nullable user, but now the components that actually want a user are forced into dealing with a lot of ambiguity. Honestly it's the same problem that plagues all of the cross cutting react APIs (Context, Redux, etc) in my opinion. You need some initial state for things, and a lot of stuff doesn't have a logical initial state that's not just "null".
    w
    a
    • 3
    • 20
  • a

    alexsullivan114

    01/10/2020, 7:52 PM
    Question - one thing I struggle with when writing Flutter apps is when to use what containing widget. There's stacks, rows, columns, containers, expanded widgets, center widgets etc etc. On the react native side, there's really only a view and then flex modifiers. It seems like compose is erring more towards the flutter style containment than the react/web style containment (though I'm aware of FlexColumn). I'd love to hear about what kind of discussion happened around that topic
    a
    • 2
    • 23
  • z

    Zsolt

    01/10/2020, 8:58 PM
    Source documentation often mentions "Example usage: @sample androidx.ui.layout.samples.#####" Are these samples available publicly somewhere?
    l
    • 2
    • 2
  • z

    Zsolt

    01/11/2020, 5:53 PM
    Is there a way to achieve baseline alignment of two Texts of different sizes in a Row? Right now they are top aligned, and Gravity.Bottom provided by Row doesn't seem to have any effect on the smaller Text when passed in as a modifier.
    • 1
    • 1
  • a

    Ash

    01/11/2020, 7:21 PM
    Does anyone have Room working with Jetpack Compose? The project compiles fine but when I try to run I get
    java.lang.NoSuchMethodError:GenerationState$Builder.isIrBackend(Z)Lorg/
    . I thought I saw a bug fix in the latest Android Studio release notes but I am still getting the error. Could someone please point me to a GitHub or other example where it is working? This a show stopper for us :- ( Thanks really appreciate everyone's help :- )
    m
    d
    t
    • 4
    • 7
  • t

    Tristan

    01/11/2020, 10:01 PM
    What's the right way to set a background color to a row? Currently I do:
    Surface(color = Color.Magenta) {
      Row(modifier = Spacing(16.dp)) {
        // ...
      }
    }
    👍 1
    m
    • 2
    • 1
  • b

    Brady Aiello

    01/12/2020, 12:25 AM
    Is there any way to inspect the "view hierarchy"? I know there is no view hierarchy so to speak, as it doesn't use views, but is there some sort of inspectable representation of the Composable function calls and their arguments used to render the UI? I'm asking chiefly programmatically, but I'm also wondering if a future version of the layout inspector will support Compose?
    a
    z
    • 3
    • 5
  • p

    Philip Blandford

    01/12/2020, 12:40 PM
    I'm trying to create a VerticalScroller that remembers its position when the page is redrawn - I've tried
    val scrollerPosition: ScrollerPosition = +memo { ScrollerPosition() }
    VerticalScroller(scrollerPosition) {
      // etc.
    }
    but it scrollerPosition.value always seems to be 0px
    m
    • 2
    • 1
  • a

    amar_1995

    01/13/2020, 7:24 AM
    VerticalScroller
    is not working properly with
    ModalDrawerLayout
    When
    drawerContent
    data wrap around verticalScroller whole view moves to center. I had tried to incoperate the samething in
    jetnews
    app. Updated the
    AppDrawer
    function
    @Composable
    private fun AppDrawer(
        currentScreen: Screen,
        closeDrawer: () -> Unit
    ) {
        VerticalScroller() {
            Column(modifier = Expanded) {
                HeightSpacer(24.dp)
                Row(modifier = Spacing(16.dp)) {
                    VectorImage(
                        id = R.drawable.ic_jetnews_logo,
                        tint = (+MaterialTheme.colors()).primary
                    )
                    WidthSpacer(8.dp)
                    VectorImage(id = R.drawable.ic_jetnews_wordmark)
                }
                Divider(color = Color(0x14333333))
                DrawerButton(
                    icon = R.drawable.ic_home,
                    label = "Home",
                    isSelected = currentScreen == Screen.Home
                ) {
                    navigateTo(Screen.Home)
                    closeDrawer()
                }
    
                DrawerButton(
                    icon = R.drawable.ic_interests,
                    label = "Interests",
                    isSelected = currentScreen == Screen.Interests
                ) {
                    navigateTo(Screen.Interests)
                    closeDrawer()
                }
            }
        }
    }
    m
    r
    • 3
    • 8
  • m

    mertceyhan

    01/13/2020, 11:10 AM
    Hello, I have a question about @Preview annotation. Why we need to it for seeing preview version of the code? Should it be the default for our screen? In my opinion, We should see a preview of every composable function in setContent.
    s
    m
    • 3
    • 2
  • i

    Ian Warwick

    01/13/2020, 12:07 PM
    any simple to understand animation examples yet? 🙂 I did some digging but nothing clicked so far, I see the cross fade anim and some infrastructure just need a nudge in the right direction
    m
    • 2
    • 11
  • s

    shikasd

    01/13/2020, 6:28 PM
    Hey, I was experimenting with Transition API and noticed that there's no way to check if user specified a key in transition definition or specify defaults. Do you plan to add support for it later? Example:
    val X = FloatPropKey()
    val Y = FloatPropKey()
    
    val def = transitionDefinition {
        state(Initial) {
            this[X] = 0f
        }
    }
    
    Transition(definition = def, initState = Initial) { state ->
        val xValue = state[X]
        val yValue = state[Y] // <-- Crashes, as no value specified
    }
    z
    • 2
    • 1
  • v

    Vincent tiensi

    01/14/2020, 7:29 AM
    Is there a resource for developing a custom widget? I can’t seem to find anything concrete as a baseline to use
    i
    • 2
    • 2
  • a

    amar_1995

    01/14/2020, 11:24 AM
    I am implementing
    BottomSheet
    using
    BottomDrawerLayout
    but in doc it written that bottomDrawer is only used with bottom app bars. So, Is it okay to make bottomSheet using BottomDrawerLayout ?
    m
    • 2
    • 24
  • s

    seb

    01/14/2020, 3:15 PM
    Have another question, is there a way to show the widget bounds in a similar fashion to “Show layout bounds”?
    a
    z
    • 3
    • 4
  • i

    Ian Warwick

    01/14/2020, 8:53 PM
    Are there any plans to support memo across config changes or would that just be wrong?
    val model = +memo { CardEditorModel() }
    a
    t
    • 3
    • 6
Powered by Linen
Title
i

Ian Warwick

01/14/2020, 8:53 PM
Are there any plans to support memo across config changes or would that just be wrong?
val model = +memo { CardEditorModel() }
a

Adam Powell

01/14/2020, 9:55 PM
Yes, we're investigating this. Worst case it'll be a different function name to opt-in but I'd like to see if we can do it by default if possible.
🙏 6
i

Ian Warwick

01/14/2020, 10:33 PM
Nice 🙂 that would be very cool!
t

Tash

01/14/2020, 10:35 PM
Would this lead to a direction where any state management in general across config changes/Activity recreation becomes trivial if your whole UI is using Compose?
:yes: 1
i

Ian Warwick

01/14/2020, 10:39 PM
I think so yep as simple as a plain old data class I guess
t

Tash

01/15/2020, 1:25 AM
Yeah having this would be very cool. Hopefully with Compose, there wont be any more contention as to what to do during config changes/Activity recreation.
a

Adam Powell

01/15/2020, 2:24 AM
if your whole activity is compose there's no reason to leave activity recreation enabled in the first place
👍 3
🙏 3
😍 6
View count: 4