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

    Yuriy Kulikov

    07/18/2020, 2:28 PM
    Do you prefer 2 or 4 spaces for Compose files? Or don't care?
    m
    j
    z
    • 4
    • 5
  • r

    romainguy

    07/18/2020, 2:34 PM
    4 spaces is always the answer :)
    🇳🇴 4
    😂 4
    ➕ 4
    y
    • 2
    • 3
  • h

    handstandsam

    07/18/2020, 4:50 PM
    Flipping it on it's head to have this Idea for theme synchronization between Android XML Themes & Compose: • Apply Compose (Kotlin Defined) styles upon Existing Android Views. This could be done by extending the current View set to make AndroidX.Button.ComposeThemed or something? You would force attributes of your Compose Defined Theme in that Android View programmatically and ignore existing style attributes. It seems like a nice way to start defining styles in Kotlin, and slowly migrating existing widgets over to use those styles. Thoughts?
    a
    • 2
    • 19
  • b

    Ben

    07/18/2020, 4:52 PM
    Hello, i'm using 0.1.0-dev13 version of the compose, is there a version of
    Seekbar
    in it?
    SeekbarPreference
    is deprecated now
    a
    • 2
    • 2
  • f

    Fudge

    07/18/2020, 7:57 PM
    How can I align elements in a row, such that one element is centered and the other is attached to the right? The following solutions do not work:
    Row(horizontalArrangement = Arrangement.Center) {
                Text("Center")
                Text("Right", modifier = Modifier.fillMaxWidth().wrapContentWidth(Alignment.End))
            }
    Row(horizontalArrangement = Arrangement.Center) {
                Text("Center")
                Spacer(modifier = Modifier.weight(1f))
                Text("Right")
            }
    As in both cases the
    Center
    element will get attached to the left. The desired behavior is in this image:
    m
    a
    • 3
    • 11
  • c

    caelum19

    07/18/2020, 9:48 PM
    Hey, how can I stop a view from being recreated on recomposition using AndroidView with the resId parameter?
    r
    h
    • 3
    • 6
  • j

    Joost Klitsie

    07/19/2020, 8:47 AM
    It seems like text input is lagging behind
    a
    • 2
    • 78
  • f

    Fudge

    07/19/2020, 1:14 PM
    How can I make an Icon visibly bigger? I've tried various size modifiers (preferred, width, height, size, etc) but they only make the icon take more space, and the icons stays just as small.
    Icon(Icons.Rounded.Search, Modifier.padding(8.dp).preferredSize(60.dp)) // Actual icon size looks around 30dp
    n
    v
    • 3
    • 5
  • i

    iex

    07/19/2020, 2:04 PM
    How to give views an absolute position (want to plot dots on a small graph, for which I'm using
    Box
    / shapes)?
    a
    • 2
    • 10
  • g

    galex

    07/19/2020, 4:13 PM
    That’s quite disappointing, is there anything I can do to make Compose aware of the inside of an object ?
    m
    a
    • 3
    • 16
  • s

    Siyamed

    07/19/2020, 4:14 PM
    Leland and Adamp (dont want to ping here on a Sunday morning) would know
    a
    • 2
    • 1
  • g

    galex

    07/19/2020, 5:31 PM
    Let’s say I have a simple app with a bottomBar and two tabs, each showing a list of items. What would be the right thing to do for opening those items? A new activity? A new screen + hiding the bottomBar with an animation? in Jetnews there is no bottomBar in the first screen, so it feels easier to just change the screen..
    s
    • 2
    • 2
  • g

    galex

    07/19/2020, 6:14 PM
    Slider
    doesn’t follow the
    steps
    and lets me drag it all over. Is this a known bug? Is the main issue tracker the right place to report issues on material design compose lib?
    m
    • 2
    • 9
  • p

    pajatopmr

    07/20/2020, 5:35 AM
    I get it is early times still in the world of jetpack compose, nevertheless I have a notion that it is not too early to raise the topic of code coverage for compose code. What would it take to get either an IntelliJ or a Jacoco coverage report for the JetNews sample app? The IntelliJ path did not look promising so I am about to explore the Gradle/Jacoco path.
    g
    s
    • 3
    • 12
  • s

    sksk

    07/20/2020, 1:35 PM
    apparently JB is planning to make compose a crossplatform UI solution https://old.reddit.com/r/androiddev/comments/hufnjq/jetbrains_is_porting_compose_to_desktop_and_other/
    🤘 1
    :kotlin-flag: 4
    🎉 16
    s
    a
    • 3
    • 2
  • q

    Quentin Dommerc

    07/20/2020, 2:06 PM
    Hey everyone! What seems to be the encouraged alternative between
    Modifier.foo() + Modifier.bar()
    and
    Modifier.foo().bar()
    ?
    f
    a
    m
    • 4
    • 5
  • f

    Fudge

    07/20/2020, 2:58 PM
    Is there a way to constrain an element absolutely, without letting it relayout itself to fit within the available space? The use case is to create a component that can swipe between different screens. (I already have it implemented, but the children keep moving around as they're getting constrained) This image illustrates the idea:
    a
    o
    • 3
    • 24
  • m

    Mehdi Haghgoo

    07/20/2020, 4:14 PM
    So Compose is a collaboration between Google and JetBrains? I thought it was only the Android team.
    a
    r
    • 3
    • 2
  • g

    galex

    07/20/2020, 6:08 PM
    I wonder what would be the best to prepare for Compose. I know we have like a year / year and a half till 1.0, so it gives us devs plenty of time to prepare at our ease. I guess a good separation between data loading and UI would be nice. I am sure apps created more than 3 or 4 years ago aren’t there yet.
    a
    j
    +2
    • 5
    • 14
  • a

    Alejandro Rios

    07/20/2020, 6:11 PM
    I dare say that since it's related to Android Studio 4.2 then when that version is ready compose will be ready too
    a
    s
    m
    • 4
    • 5
  • g

    galex

    07/20/2020, 6:52 PM
    What about Portrait vs Landscape with Compose ? Are we just going to build two Composables? What about tablets?
    l
    s
    • 3
    • 8
  • f

    Fudge

    07/20/2020, 7:47 PM
    Consider the following code
    Column {
            var on by state { true }
    
            Button(onClick = { on = !on }) {
                Text(text = "Toggle", style = textStyle.h1)
            }
    
            val list = @Composable {
                LazyColumnItems(items = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) {
                    Text(text = it.toString(), style = textStyle.h1)
                }
            }
            if (on) {
                list()
            } else {
                list()
            }
        }
    Here we have a scrolling list, with a button above it, that seemingly, does nothing. However, it doesn't - it resets the current scroll progress in the scrolling list. I have a feeling this is the intended behavior (unfortunately). I have a less trivial case where the same list is being used at multiple places, but it loses its scroll progress when it gets invoked through a different branch of code. It might be possible to somehow structure the code such that only one invocation occurs, but I find that difficult. Is there some way to make compose understand this is the same list?
    r
    j
    +2
    • 5
    • 13
  • y

    Yamila Gammeri

    07/21/2020, 3:47 AM
    Is there a tutorial or a page for localization with Jetpack Compose?
    s
    • 2
    • 1
  • t

    Thiago

    07/21/2020, 3:53 AM
    I found using dev14. There is a big ripple to the FilledField when clicked. And I can grab the label to copy the text. Are those actions expected already?
    setContent {
                MaterialTheme(
                    colors = lightColorPalette(
                        background = colorResource(id = R.color.loginPageBackgroundColor),
                        primary = colorResource(id = R.color.colorPrimary),
                        primaryVariant = colorResource(id = R.color.colorPrimaryDark),
                        secondary = colorResource(id = R.color.colorAccent)
                    )
                ) {
                    Column(
                        modifier = Modifier.fillMaxSize(),
                        horizontalGravity = Alignment.CenterHorizontally,
                        verticalArrangement = Arrangement.Center
                    ) {
                        var text by savedInstanceState { "" }
    
                        FilledTextField(
                            modifier = Modifier.fillMaxWidth(),
                            value = text,
                            onValueChange = { text = it },
                            label = { Text(text = "Username") },
                            keyboardType = KeyboardType.Email,
                            imeAction = ImeAction.Done
                        )
                    }
                }
            }
    recording.mp4
    l
    s
    +3
    • 6
    • 11
  • g

    galex

    07/21/2020, 6:44 AM
    Where does Compose stand about Material Motion? https://material.io/design/motion/the-motion-system.html I love the look of those transitions 😍
    m
    • 2
    • 8
  • v

    vanpra

    07/21/2020, 10:10 AM
    Hey everyone! For the last few weeks I've been working on a material dialog library for compose which provide the basis and common components for building a material speced dialog. This includes things such as single and multi-selection lists, date and time picker and a colour picker. I'd love to get some feedback on it and I'm open to any suggestions for other common dialog components that should be implemented. https://github.com/vanpra/compose-material-dialogs
    👍 9
    👏 4
    p
    c
    • 3
    • 3
  • t

    Thiago

    07/21/2020, 4:31 PM
    Hi folks, I'm here again. This time with a vector drawable not rendering correctly. I'm re-learning Compose porting this codelab: https://codelabs.developers.google.com/codelabs/mdc-101-kotlin/#0
    Image(asset = vectorResource(id = R.drawable.shr_logo))
    In the picture we can see Shrine logo rendering filled instead the path. PS: the logo that is not rendering correctly. Others are rendering fine. compose:
    0.1.0-dev14
    n
    • 2
    • 1
  • g

    galex

    07/21/2020, 5:23 PM
    Do we have a Composable for bottom bar with a cradled fab like this one -> https://material.io/develop/android/components/app-bars-bottom ?
    m
    • 2
    • 9
  • f

    Fudge

    07/21/2020, 7:12 PM
    Why are
    MutableState<T>.setValue
    /
    MutableState<T>.getValue
    extension methods instead of instance methods? This creates some confusion for me when I write
    by state{}
    and it errors, and I need to use the import quickfix.
    z
    a
    l
    • 4
    • 4
  • s

    Sergey Y.

    07/21/2020, 8:36 PM
    Is Compose prone to problems similar to which a deeply nested Android ViewGroup suffers? I mean double layout taxation, slow measure/layout phases, etc. On Android, we always tried to build a flat view hierarchy, without deep nesting or weights. And what with Compose?
    z
    r
    +3
    • 6
    • 31
Powered by Linen
Title
s

Sergey Y.

07/21/2020, 8:36 PM
Is Compose prone to problems similar to which a deeply nested Android ViewGroup suffers? I mean double layout taxation, slow measure/layout phases, etc. On Android, we always tried to build a flat view hierarchy, without deep nesting or weights. And what with Compose?
z

Zach Klippenstein (he/him) [MOD]

07/21/2020, 8:37 PM
Compose’s layout system forbids double layout passes, so it’s specifically designed to avoid that particular problem.
A slow layout is going to be slow no matter what, so if you have a really complex ConstraintLayout, it will be slower than a simple
Row
. That said, there’s been lots of talk about shoving some Composition work onto background threads, which might mitigate that problem (it’s not been super clear exactly what that will look like yet).
Some more discussion about layout performance here: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1594751832267800?thread_ts=1594598732.179100&amp;cid=CJLTWPH7S
👍 1
And @Leland Richardson [G] just posted a tweet about how a recent change to make the common layouts
Row
and
Column
inline functions had a huge performance benefit: https://twitter.com/intelligibabble/status/1285642262454640645?s=20
s

Sergey Y.

07/21/2020, 8:43 PM
Wow, great news. Thanks.
Does Compose could inline or merge some view constructions to a single layout? For instance, a text and an icon?
Or I think it doesn't make any sense because Compose already is drawing on Canvas.
z

Zach Klippenstein (he/him) [MOD]

07/21/2020, 8:48 PM
There are semantics operators to let you group the sets of layouts that accessibility tools like TalkBack see, but I don’t think that’s what you’re asking. Compose won’t merge layouts, but it shouldn’t need to. If nothing in a Composable changed, and it doesn’t need to be re-measured, then it shouldn’t be re-composed (or re-measured, or re-layed-out, or re-drawn, etc).
👍 1
s

Sergey Y.

07/21/2020, 8:48 PM
lovely
r

romainguy

07/21/2020, 8:50 PM
@Sergey Y. The existing View system draws on Canvas too
That’s not relevant to merging
s

Sergey Y.

07/21/2020, 8:50 PM
Well I mean the measuring
r

romainguy

07/21/2020, 8:50 PM
Anyway on your original question:
👍 1
Yes Compose will prevent layouts that work in multiple passes
but
Deep nesting means deeper call stacks, more code to execute, more state to track, potentially more complex drawing trees, more allocations, etc.
No matter what, doing less is always going to beat doing more 🙂
So: profile your app
If it’s too slow, optimize it, otherwise you’re good 🙂
l

Leland Richardson [G]

07/21/2020, 8:54 PM
lol. finally, i have the answer to all of my performance woes 🙂
🤣 4
s

Sergey Y.

07/21/2020, 8:54 PM
So: profile your app
and keep calm. Yes, I know Colt's tagline 🙂 #perfmatters
r

romainguy

07/21/2020, 8:55 PM
@Leland Richardson [G] Performance work is pretty easy turns out, just make slow things fast!
l

Leland Richardson [G]

07/21/2020, 8:57 PM
As @Chuck Jazdzewski [G] once told me, all performance improvements end up boiling down to one of: 1. do less work 2. do work less often 3. use information you weren’t using before
👏 2
🙌 1
OK, I think we’ve sufficiently derailed this thread now…
❤️ 1
c

Chuck Jazdzewski [G]

07/21/2020, 9:00 PM
The actual quote is, 1. do less 2. do it less often 3. do it some other time
❤️ 1
🙌 1
The "use information you weren't using before" helps with the above.
l

Leland Richardson [G]

07/21/2020, 9:00 PM
ah, i knew i was gonna mess it up
this is why we have you do the perf work
c

Chuck Jazdzewski [G]

07/21/2020, 9:01 PM
You can still do 2/3 of the perf work...
🤣 7
r

romainguy

07/21/2020, 9:08 PM
Taking notes…
c

curioustechizen

07/22/2020, 5:09 AM
Why is this gem of a discussion hidden inside a slack thread? Why? I demand it be spun out into a Twitter thread or something. Especially those quotes 😛
View count: 1