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

    mattinger

    10/06/2020, 5:14 PM
    Anyone else able to solve the issue yet of the compose sources not being shown, and instead viewing the compiled .class file?
    l
    • 2
    • 1
  • a

    Arkadii Ivanov

    10/06/2020, 5:40 PM
    Hello! When
    rememberScrollState
    is used inside
    Crossfade
    , it receives different generates keys every time the screen is rotated. This prevents the state from being restored and also causes more and more keys accumulating in the
    UiSavedStateRegistryAmbient
    . Is it expected behaviour or a bug?
    l
    a
    • 3
    • 6
  • m

    mattinger

    10/06/2020, 5:47 PM
    Have a question about theming. For things like typography, the values seem to be relatively static. However, if you look at material theme colors, those fields are specifically declared as mutable state and the constructor parameters are not properties, but simply values that are used for creating the mutable state instances. Why is this?
    z
    l
    • 3
    • 7
  • g

    Guy Bieber

    10/06/2020, 10:25 PM
    The mutableMapStateOf does not appear to maintain the order of the map when you iterate as mutableMapOf does. It randomly reorders my tabs. Any recommendations or is this a known bug?
    j
    g
    c
    • 4
    • 11
  • s

    Sam

    10/06/2020, 11:39 PM
    Does Jetpack Compose have anything similar to the NavigationView in SwiftUI? Specifically: traversing deeper into a stack of screens with back button, swipe back to navigate, and of course the slide animation, etc. I know there is
    ModalDrawerLayout
    but that is more for a side menu..
    i
    z
    +3
    • 6
    • 21
  • s

    streetsofboston

    10/06/2020, 11:41 PM
    I googled a bunch, but I couldn't find an answer to my question: How do you get the layed out height (or width) of a Compose component? I'd like to use the height of a LazyColunnFor to see if a ListItem is in the center of it (and scale it accordingly, based on how far away the ListItem is from that center).
    y
    s
    • 3
    • 3
  • s

    sindrenm

    10/07/2020, 9:52 AM
    Is there a relatively straight-forward way of removing the bottom indicator line in (filled) `TextField`s? I found
    Modifier.drawIndicatorLine()
    in TextField.kt but it's private. I could go ahead and make a “completely” custom text field using
    BaseTextField
    , I guess, it's just that
    TextField
    already had placeholders, leading/trailing icons and shapes and stuff built-in.
    s
    m
    r
    • 4
    • 9
  • p

    Prashant Priyadarshi

    10/07/2020, 11:42 AM
    Hello, I am trying to align a card to center horizontal. But the new align is new working. Can somebody please help me figure out what am I missing/doing wrong.
    @Composable
    fun getSampleDataUI(list : List<SampleData>){
    MaterialTheme {
    LazyColumnFor(modifier = Modifier.fillMaxWidth(),
    items = list) {item ->
    ColumnScope.getSampleDataRow(data = item)
    }
    }
    }
    @Composable
    fun ColumnScope.getSampleDataRow(data: SampleData){
    return Card(modifier = Modifier.padding(15.dp).zIndex(5.0f)
    .align(Alignment.CenterHorizontally)) {
    Column(modifier = Modifier.padding(10.dp))
    {
    CoilImage(data.url, modifier = Modifier.size(50.dp).clip(CircleShape))
    Text(text = data.value)
    Text(text = data.value)
    }
    }
    }
    a
    • 2
    • 9
  • s

    streetsofboston

    10/07/2020, 2:38 PM
    Another question 🙂 How can I mimic the Android views’
    clipChildren=false
    and
    clipToPadding=false
    ?
    a
    a
    • 3
    • 14
  • a

    Alejandro Rios

    10/07/2020, 4:00 PM
    Hi guys, one question, if have an existing app and I'm thinking to migrate some screens to compose, is there any problem related to the use of compose with
    synthetics
    ?, should I use
    dataBinding
    or
    viewBinding
    instead of
    synthetics
    ?
    🙌 1
    r
    s
    +4
    • 7
    • 7
  • c

    Colton Idle

    10/07/2020, 8:27 PM
    Why does compose have both Column and LazyColumnFor? It seems like everyone could just potentially benefit from using LazyColumnFor and getting rid of Column (or putting LazyColumn functionality into Column, and removing Column) could work? I only bring that up because I think I remember reading that @elihart said something along the lines of ~"Airbnb uses Epoxy even for lists that are completely heterogenous because RecyclerView will still only draw what needs to be on the screen which is a net benefit". I think Eli said that when someone asked like if using Epoxy was okay for using on all screens of an app, even the ones that don't even need a RecyclerView. Even taking Elis comments out (in case I'm imagining things) wouldn't just having a single abstraction for laying things out in a list be good for simplicity, and the list just knows how to "recycle" things if needed? Basically, theoretically wouldn't every list benefit from being in a RecyclerView/LazyColumnFor?
    z
    r
    +2
    • 5
    • 10
  • l

    louiscad

    10/07/2020, 8:38 PM
    Are the performances of Compose in a ViewGroup (passed to
    setContentView
    in an Activity) the same as Compose at the root of an Activity, or is there layout render node related optimizations or whatever that cannot take place when Compose is used in a
    ViewGroup
    ?
    z
    r
    a
    • 4
    • 16
  • s

    sindrenm

    10/08/2020, 7:11 AM
    How would I go about constraining the top of one composable to the (vertical) center of another composable? I don't initially know the size of any of them. Is there a way to get the size of a composable post-measure? Thanks. 😒imple_smile:
    j
    z
    • 3
    • 21
  • g

    Geert

    10/08/2020, 8:59 AM
    I was updating to alpha04, but I saw gravity was deprecated and align was the automatic replacement. So i used Android Studio to replace it, but align wasn’t imported, and could not be. Except doing this by hand I noticed. Also the autocomplete for this is gone. Is this a known issue?
    a
    a
    • 3
    • 5
  • s

    Socheat KHAUV

    10/08/2020, 9:59 AM
    Any example about LazyColumnFor + LiveData + Pagination (Page3, LoadMore) etc ?
    g
    a
    • 3
    • 3
  • o

    Omar Miatello

    10/08/2020, 2:06 PM
    Is there a tool to convert an xml layout into an @Composable function? It could be useful for migration purposes
    z
    a
    c
    • 4
    • 7
  • j

    JimK

    10/08/2020, 3:26 PM
    I'm experimenting with Compose interoperability. I have an xml layout that defines a debug drawer and then my compose view for the rest of the application. The debug drawer is a fragment with its own View using the regular Android View. The displaying Compose screen is a simple login form.
    java.lang.IllegalStateException: KeyEvent can't be processed because this key input node is not active.
    When I hit tab on the emulator to switch fields, I get this exception; is this attempting to forward the keyevent to the hidden drawer fragment? I'm unsure why adding the AndroidView would cause this
    r
    • 2
    • 2
  • b

    bruno.aybar

    10/08/2020, 4:45 PM
    Hello, Regarding the issue downloading sources in latests AS versions: https://issuetracker.google.com/issues/169575797  The last comment says that the fix is coming in the first beta of 4.2. I was wondering if that’s coming any time soon, or if we’ll have to deal with that issue for a few more canary versions?
    👀 2
    s
    c
    j
    • 4
    • 7
  • s

    Sam

    10/08/2020, 7:06 PM
    This is quite possibly the dumbest question ever, but how do I actually browse files on googlesource.com? Looking for the dev branch (I think
    androidx-master-dev
    ?) so I can browse
    compose/navigation/navigation/samples/src/main/java/androidx/compose
    . It’s so different than github/gitlab and I have no idea why tapping the branch doesn’t take me to a directory of files
    i
    e
    c
    • 4
    • 10
  • g

    Guy Bieber

    10/08/2020, 9:07 PM
    I am trying to a selector that picks a card and scrolls a card at a time. Is there a way to get a ScrollableRow or HorizontalList to snap on each item. Recommendations appreciated!! This is close, but no snap:
    @Composable
    private fun PagerLikeDemo() {
        val pages = listOf(Color.LightGray, Color.White, Color.DarkGray)
        LazyRowFor(pages) {
            Spacer(Modifier.fillParentMaxSize().background(it))
        }
    }
    z
    p
    • 3
    • 5
  • s

    Sam

    10/08/2020, 11:21 PM
    What’s the best way to create a
    Button
    with a
    LinearGradient
    for the background? I see that the Button composable is not that hard to recreate, but internally using a
    Surface
    which takes a
    Color
    . Does this mean I have to recreate both
    Surface
    and it’s private composable
    SurfaceLayout
    to achieve a gradient background?
    i
    • 2
    • 1
  • s

    Sam

    10/09/2020, 12:27 AM
    How do I enable P3 color for Jetpack Compose? I have
    <activity android:colorMode="wideColorGamut" …>
    in
    AndroidManifest.xml
    and using the colorSpace but it definitely does not look like the right color:
    Color(red = r, green = g, blue = b, alpha = 1f, colorSpace = ColorSpaces.DisplayP3)
    r
    n
    • 3
    • 10
  • a

    Afzal Najam

    10/09/2020, 1:36 AM
    Apparently you can use Kotlin 1.4.20-M1, but just have to
    kotlinCompilerVersion
    set to 1.4.10 in
    composeOptions
    in
    build.gradle
    j
    • 2
    • 2
  • k

    Karthick

    10/09/2020, 3:38 AM
    Is compose navigation ready?
    i
    a
    a
    • 4
    • 23
  • c

    Christian

    10/09/2020, 4:00 AM
    Hi, anybody encountered this problem when upgrading to alpha04
    Cannot import 'weight', functions and properties can be imported only from packages or objects
    on Jetpack-Compose-Playground-master project?
    s
    v
    • 3
    • 2
  • i

    Irving

    10/09/2020, 7:16 AM
    Hello, I'm new to Jetpack Compose. I'm confused about how do Touch Events be handled by Compose. For example, if I want to write a custom view and handle touch events by myself. I could override onTouchEvent to do complex gestures before, but how could I do by Compose?
    🤣 1
    a
    a
    b
    • 4
    • 8
  • s

    Sam

    10/09/2020, 7:25 AM
    I know this has been discussed since
    alpha04
    came out, but I searched every answer here along with
    compose-samples
    . How do we horizontally center all children in a
    Column
    ? This doesn’t compile:
    Column(Modifier.align(Alignment.Horizontal)) { ... }
    And this compiles but doesn’t do the job:
    Column(Modifier.align(Alignment.CenterHorizontally)) { ... }
    I’ve resorted to putting
    Modifier.align(Alignment.CenterHorizontally)
    on all the children within the Column, but I’m betting that’s not the intended solution.
    a
    • 2
    • 4
  • g

    Gabriel

    10/09/2020, 11:08 AM
    Do we still use xml files for values? I've tried pruning the ones generated down but I still have colors, strings and 2xthemes files
    a
    n
    • 3
    • 6
  • c

    Chethan

    10/09/2020, 11:22 AM
    Hi , How can I give layout margin around the view ? margin means the space outside the view, however padding means the space inside the view , why does it so complex to make here in the Compose ? I am not seeing any example of it ?
    a
    s
    • 3
    • 17
  • f

    fabio.carballo

    10/09/2020, 11:36 AM
    hey, what is the recommended approach (if any) to model the color of enabled/disabled states for a specific
    Typography
    ? in the previous theming system we relied in
    color selectors
    . I guess there is nothing equivalent in Compose.
    n
    n
    • 3
    • 4
Powered by Linen
Title
f

fabio.carballo

10/09/2020, 11:36 AM
hey, what is the recommended approach (if any) to model the color of enabled/disabled states for a specific
Typography
? in the previous theming system we relied in
color selectors
. I guess there is nothing equivalent in Compose.
n

nickbutcher

10/09/2020, 1:50 PM
val emphasis = AmbientEmphasisLevels.current
ProvideEmphasis(if (enabled) emphasis.high else emphasis.disabled) {
  Text(…)
}
n

nglauber

10/09/2020, 3:51 PM
@nickbutcher is this the same?
val emphasis = EmphasisAmbient.current
n

nickbutcher

10/09/2020, 3:54 PM
yes it was renamed https://android-review.googlesource.com/c/platform/frameworks/support/+/1311696
👍 1
f

fabio.carballo

10/14/2020, 2:34 PM
thanks!
View count: 2