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

    Karthick

    02/18/2021, 9:21 AM
    can AppBar has an option to center title, like in flutter. Some users prefer title in the center
    AppBar(centerTitle: true, title: Text("Title"))
    😿 2
    a
    • 2
    • 3
  • k

    Kshitij Patil

    02/18/2021, 11:23 AM
    What’s the right way of conditionally adding Modifiers? I tried
    Modifier.padding()
    .preferredSize()
    .apply {
        if(<some condition>) {
            this.then(Modifier.clickable { })
        }
    }
    but didn’t work
    d
    g
    a
    • 4
    • 6
  • a

    alorma

    02/18/2021, 11:27 AM
    Hi. I'm getting:
    * What went wrong:
    lateinit property variantName has not been initialized
    When trying to build my project form command line Config:
    com.android.tools.build:gradle:7.0.0-alpha06
    6.8.2-all.zip
    compose
    alpha12
    j
    • 2
    • 3
  • d

    David Edwards

    02/18/2021, 12:19 PM
    Is there a replacement for
    Spinner
    yet?
    j
    a
    • 3
    • 11
  • t

    Timo Drick

    02/18/2021, 1:27 PM
    PaddingValues is since alph12 just an interface what makes it very difficult to add or substract values. E.g. i want to add a FAB padding to the content padding of my LazyColumn. How can i do it now?
    g
    a
    • 3
    • 8
  • b

    Bradleycorn

    02/18/2021, 1:54 PM
    Perhaps a Studio question more-so than compose, but ... has anyone else had trouble getting the debugger to attach since updating everything to latest stuff for alpha 12?
    d
    • 2
    • 12
  • g

    Geert

    02/18/2021, 2:16 PM
    I just tried to add a onbackpress dispatcher to a composable function. It works, but should I place it the function, SideEffect, LaunchedEffect, or DisposableEffect? I have to add it since it needs the call popBackStack() multiple times (or popUpTo)
    a
    i
    • 3
    • 2
  • l

    Lukas K-G

    02/18/2021, 2:51 PM
    I shere a way to get hold of a Surface in compose?
    z
    k
    • 3
    • 5
  • s

    Simone Summo

    02/18/2021, 3:35 PM
    Hi all, I have made a custom composable for a Searchbar that takes as input a
    query
    and an
    onValueChange: (String?) -> Unit
    . The idea is that when I have the
    onValueChange
    with the string as null the UI is different and the TextField is empty, but I get an error when I call my onValueChange inside the clickable of the close icon. The error I get:
    java.lang.AssertionError: org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl@63ae5d17: No such type argument slot: 1
    j
    s
    • 3
    • 2
  • a

    Alexander Karkossa

    02/18/2021, 3:50 PM
    @cb  I have a question about the ViewModels in the JetCaster app. https://github.com/android/compose-samples/blob/master/Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/HomeViewModel.kt#L46 The state/_state variable (MutableStateFlow) is set by a collect on a combine in a launch on the viewModelScope.
    val state: StateFlow<HomeViewState>
        get() = _state
    
      init {
        viewModelScope.launch {
          combine(
            ...
          }.collect {
            _state.value = it
          }
        }
      }
    Why don't use return value of the combine method directly to the state variable?
    val state = combine(
        ...
      )
    Can someone explain the benefits of viewModelScope.launch -> collect in the init?
    a
    c
    • 3
    • 7
  • e

    escodro

    02/18/2021, 5:02 PM
    Hello, everyone! 😊 I have a complex Composable function that I decided to create two ViewModels in order to better split the responsibilities and both of them emits state (
    sealed classes
    via
    StateFlow
    ). How could I handle the state changes? 1. Combine both states (with
    .combine
    ) and create a third “ViewState” mixing and matching the two states. 2. Observe both individually and let my function recompose when they change 3. Another better approach? The first ViewModel has three states: EmptyList, LoadedList, Error and the second one has two: DataLoaded and Error. Thanks and advance! 🎉
    👍 1
    a
    c
    • 3
    • 23
  • a

    alorma

    02/18/2021, 6:14 PM
    Hi. Weird question Is it possible, from a module (library), having
    MaterialTheme
    , to obtain the
    light
    or
    dark
    version of a MaterialTheme?
    j
    • 2
    • 10
  • j

    julioromano

    02/18/2021, 6:37 PM
    Is it possible to create deep link pending intents with
    navigation-compose
    ? Previously I was using
    NavDeepLinkBuilder
    but I can’t seem to get it work with compose.
    ✅ 1
    i
    • 2
    • 4
  • r

    romainguy

    02/18/2021, 6:40 PM
    FYI: https://twitter.com/AndroidDev/status/1362469578635362305
    :party-parrot: 16
    🙌🏼 14
    :jetpack-compose: 7
    z
    • 2
    • 1
  • z

    Zach Klippenstein (he/him) [MOD]

    02/18/2021, 6:51 PM
    Are there docs anywhere for how to tell Android Gradle Plugin pre-4.2 what the correct Compose compiler dependency is? I am trying to build some compose code in a project that can’t use 4.2 yet, and it looks like agp 4.1 is trying to use obsolete compiler dependency coordinates.
    j
    l
    • 3
    • 8
  • j

    Jakub Ledwon

    02/18/2021, 7:13 PM
    Hi there, I'm migrating from compose 11 to 12 and It is recommended to use
    Animatable
    instead of
    AnimatedFloatModel
    , I was using
    fling
    and as
    Animatable
    has no fling method I've switched to using
    animteDecay
    , what I need is some way to use both
    decay
    and
    adjustTarget
    as I did with
    AnimatedFloatModel
    how can I achieve it now?
    d
    t
    • 3
    • 7
  • c

    Colton Idle

    02/18/2021, 8:38 PM
    Any easy way to use a TopAppBar with centered title?
    d
    • 2
    • 4
  • s

    Sergey Y.

    02/18/2021, 10:41 PM
    1576883: Concurrent recomposition API | https://android-review.googlesource.com/c/platform/frameworks/support/+/1576883 Status:
    Merged
    . Does this tell us we will have multithreaded composition soon? ☺️
    j
    a
    +2
    • 5
    • 19
  • g

    Gabriel

    02/18/2021, 11:28 PM
    I've got a strange issue, I've deployed a preview to the emulator, and now it wont show anything else! It'll only run the preview, I've tried cleaning and building, I've tried uninstalling the app from the emulator, but it just keeps showing the preview
    z
    • 2
    • 2
  • c

    Cash Hsiao

    02/19/2021, 10:02 AM
    I want to ask about an issue of DialogFragment. I create a DialogFragment using ComposeView which is normally work in alpha10:
    class TestDialogFragment : DialogFragment() {
        override fun onCreateView(
            inflater: LayoutInflater,
            container: ViewGroup?,
            savedInstanceState: Bundle?
        ) = ComposeView(requireContext()).apply {
            setContent {
                Surface {
                    TestDialogLayout()
                }
            }
        }
    }
    It's all normal with the deploy Preview
    @Preview
    @Compose
    fun PreviewTestDialog() {
        TestDialogLayout()
    }
    But when I navigate from other fragment like:
    TestDialogFragment().show(childFragmentManager, "Test")
    or navigation way:
    findNavController().navigate(MainFragmentDirections.actionToTestDialog())
    Both calls gave me this crash log:
    java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from DecorView@bec849f[MainActivity]
            at androidx.compose.ui.platform.WindowRecomposerKt.createLifecycleAwareViewTreeRecomposer(WindowRecomposer.kt:231)
            at androidx.compose.ui.platform.WindowRecomposerKt.access$createLifecycleAwareViewTreeRecomposer(WindowRecomposer.kt:1)
            at androidx.compose.ui.platform.WindowRecomposerFactory$Companion$LifecycleAware$1.createRecomposer(WindowRecomposer.kt:115)
            at androidx.compose.ui.platform.WindowRecomposerPolicy.createAndInstallWindowRecomposer$ui_release(WindowRecomposer.kt:168)
            at androidx.compose.ui.platform.WindowRecomposerKt.getWindowRecomposer(WindowRecomposer.kt:216)
            at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.kt:184)
            at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.kt:215)
            at android.view.View.dispatchAttachedToWindow(View.java:19553)
    I'm not sure what happened during the alpha10 to alpha12... anyone has idea?
    v
    i
    j
    • 4
    • 12
  • s

    Se7eN

    02/19/2021, 3:08 PM
    How do I make a canvas to write text on, draw images like stickers, etc.? I'm trying to make something like a photo editor. Should I use
    ImageBitmap
    ? If yes, how do I draw text on the bitmap since there's no
    drawText
    for
    Canvas(bitmap)
    d
    • 2
    • 3
  • s

    Shakil Karim

    02/19/2021, 4:40 PM
    I have simple app with list but it has huge performance issues, Where should I start looking for potential issue with AS profiler?
    👀 2
    a
    • 2
    • 1
  • l

    Lilly

    02/19/2021, 7:49 PM
    I would like to store a Parcelable type via
    rememberSaveable
    but it doesn't get restored, instead it jumps always into the init method of
    rememberSaveable
    . What am I doing wrong?
    val navigator: Navigator<T> by rememberSaveable(
            stateSaver = Navigator.saver(backDispatcher = backDispatcher),
            key = "State
        ) {
            println("initial")
    
            mutableStateOf(
                Navigator(
                    initialConfiguration = initialConfiguration,
                    backDispatcher = backDispatcher
                )
            )
        }
    
            fun <T : Parcelable> saver(
                backDispatcher: OnBackPressedDispatcher
            ) = listSaver<Navigator<T>, T>(
                    save = { navigator -> navigator.backStack.toList() },
                    restore = { backStack -> Navigator(backStack, backDispatcher) }
                )
    I noticed that
    rememberSaveable
    is called internally multiple times, first time with my provided key and the other times it jumps into the else branch and generates a hash. Is this a bug? rememberSaveable:
    val finalKey = if (!key.isNullOrEmpty()) {
            key
        } else {
            currentCompositeKeyHash().toString()
        }
    a
    • 2
    • 6
  • t

    Tristan

    02/20/2021, 3:32 AM
    Hello, is it possible to tint an icon to only a certain percent of its size? Something like half filled from left to right. I am trying to do a rating bar with stars, and would like to have the last star only filled at the certain percent (depending on the rate)
    m
    • 2
    • 3
  • k

    Kshitij Patil

    02/20/2021, 6:15 AM
    I’m looking for a complete example of
    SubComposeLayout
    . The compose sample has given sort of Scaffold of it and I’m not able not understand its usage from it. The layout I’m trying to build is as follows: my approach was to use
    Text
    as “mainContent” and pass its dimensions to a
    Canvas
    “dependentContent” to draw those accompanying lines. Any other suggestions/approaches are welcome
    a
    • 2
    • 3
  • m

    Mehdi Haghgoo

    02/20/2021, 7:56 AM
    Hi. Can we expect Jetpack Compose beta launch on Feb 24?
    :yes: 5
    l
    z
    c
    • 4
    • 6
  • m

    Marcello Galhardo

    02/20/2021, 11:44 AM
    Hi. Is there a Material Motion API for Navigation with Compose (or Compose in general)? Motion docs here: https://material.io/develop/android/theming/motion
    a
    i
    c
    • 4
    • 5
  • o

    Orhan Tozan

    02/20/2021, 1:23 PM
    Compose Beta is expected to release soon. People that already are using Compose, how is the performance compared to the Android View system?
    😭 3
    s
    z
    +3
    • 6
    • 19
  • m

    Mehdi Haghgoo

    02/20/2021, 3:48 PM
    I sometimes hear Compose UI. For example here and there. And Compose UI sounds temptingly nice. Is Compose UI another or a new name for Jetpack Compose?
    d
    a
    t
    • 4
    • 35
  • s

    Samir Basnet

    02/20/2021, 4:10 PM
    .align is not available in alpha12. How to align individual children inside a Box?
    d
    • 2
    • 2
Powered by Linen
Title
s

Samir Basnet

02/20/2021, 4:10 PM
.align is not available in alpha12. How to align individual children inside a Box?
d

Denis

02/20/2021, 4:11 PM
You need to import it afaik
👍 1
s

Samir Basnet

02/20/2021, 4:13 PM
Hmm seems its broken in autocomplete. Typed it manually and it worked. Thanks
👍 1
View count: 1