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

    Colton Idle

    08/27/2022, 4:58 AM
    Has anyone gotten live edit to work recently? I used to use it mostly fine, but as of late in canary 9 (and canary 10 released a few hours ago) still nothin. Feels bad having it disabled for like the past month+
    k
    a
    • 3
    • 5
  • z

    zt

    08/27/2022, 6:52 AM
    How can I make a toggle button without an icon using the latest beta of the material 3 library?
  • r

    Rafs

    08/27/2022, 8:01 AM
    Did you by any chance find a solution to this issue? 1 year later and i find myself in a similar predicament.
  • r

    Rafs

    08/27/2022, 9:31 AM
    I’m trying to cache an android view and use it across configuration changes but I keep running into an
    IllegalStateException
    . The android view is a
    TextureView
    that i’m using for a webRTC call so I don’t want to restart the whole calling process on config changes. I’m handling configChanges manually as follows
    android:configChanges="orientation|smallestScreenSize|screenSize|screenLayout"
    And reusing the Surface as follows ()
    val context = LocalContext.current
    
    
    val surface = remember {
        MyTexture(context)
    }
    
    LaunchedEffect(Unit){
        // some legacy webrtc code which initialises call and sends frames to the texture view
        callController.initialise(surface)
    }
    
    AndroidView(factory = {surface})
    The error message says
    Pending composition has not been applied
    initialising the view in the factory method prevents this exception from getting thrown, but that will mean re-building a new call whenever the user rotates their device. I have 2 options now, re-architect a legacy app to work properly in this situation by removing the dependency on the
    TextureView
    during call initialisation or find a way to workaround this problem. I’m currently leaning towards the latter. Posting StackTrace in thread…
    • 1
    • 1
  • a

    Arjun Achatz

    08/27/2022, 2:41 PM
    I'm working on a brand new compose app & I was wondering what most people use for compose navigation these days : 1️⃣ Jetpack compose navigation + accompanist 2️⃣ Compose destinations 3️⃣ Appyx 4️⃣ Voyager 5️⃣ Decompose Please vote with your number; if you're using something else feel free to comment below 🧵
    p
    j
    +10
    • 13
    • 43
  • o

    oday

    08/27/2022, 9:18 PM
    I think it’s pretty clear from the code what I’m trying to do, is this the most ideal way to do it?
    @AndroidEntryPoint
    class MainActivity : ComponentActivity() {
    
        @Inject
        lateinit var prefs: SharedPreferences
    
        private val viewModel: MainViewModel by viewModels()
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
    
            lifecycleScope.launch {
                viewModel.state.collect { uiState ->
                    when (uiState) {
                        is MainViewModel.MainState.Loading -> {
                            Log.d("MainState", "Loading...")
                        }
                        is MainViewModel.MainState.Success -> {
                            setContent {
                                uiState.user?.let { Home(user = it) }
                            }
                        }
                        is MainViewModel.MainState.Error -> {
                            setContent {
                                Authentication()
                            }
                        }
                    }
                }
            }
        }
    }
    s
    • 2
    • 4
  • a

    AmrJyniat

    08/28/2022, 10:08 AM
    I see that we have two ways to make constraints in constraintLayout,
    constraintSet
    and
    createRefs()
    . Are there any tips about when should I use which and why?
  • j

    Jasmin Fajkic

    08/28/2022, 3:43 PM
    What is easiest way to make this screen? Background should be Box with fillMaxSize and image as content but how then to position title in center, logo and bottom part? Any advice? Thx in advance.
    k
    • 2
    • 4
  • t

    Trevor Hackman

    08/28/2022, 5:25 PM
    Hi ✋ I'm using BringIntoViewRequester to scroll items that aren't fully on-screen onto the screen within a LazyRow. The problem is I want to change the animation being used to bring them onto screen. Mainly I want something much slower than the built-in spring animation. Is there a way to do this?
    z
    • 2
    • 4
  • e

    ephemient

    08/29/2022, 1:44 AM
    https://issuetracker.google.com/issues/187339385
  • a

    Alex

    08/29/2022, 6:51 AM
    Is there a way to draw outside of a composables bounds? Or to render a nested composable on top of (higher z-Index) as a composable that has a different parent? e.g.
    Box {
      Box { 
        Composable1() <-- render this "on top of" (higher zIndex) Composable2
      }
      Composable2()
    }
    o
    s
    • 3
    • 4
  • d

    deviant

    08/29/2022, 1:08 PM
    hey guys. looks like
    pointerInput
    modifier doesn't work with
    Button
    . how can i detect
    on released
    event on a button?
    o
    • 2
    • 1
  • g

    Gal Kohen

    08/29/2022, 1:10 PM
    Hi, Does anyone now what are the risks using “@OptIn(ExperimentalComposeUiApi::class)” ? Can it cause a run time exceptions when it will change in the future?
    d
    • 2
    • 3
  • j

    Josh Pollock

    08/29/2022, 1:52 PM
    I really like the ideas behind Compose! I noticed that Compose, Flutter, and SwiftUI all use similar layout techniques of (i) parent constrains child, (ii) child picks size, (iii) parent places child. Does anyone know where this layout technique originally came from? Is there tool that came before these three that uses the same idea?
    e
    • 2
    • 2
  • j

    jossiwolf

    08/29/2022, 2:57 PM
    Swipeable users, are any of you using
    thresholds
    to define custom thresholds based on the origin and/or target? For example:
    Box(Modifier.swipeable(thresholds = { from, to -> if (from == A) FixedThreshold(56.dp) else FractionalThreshold(0.5f) }))
    d
    • 2
    • 1
  • s

    Stylianos Gakis

    08/29/2022, 3:10 PM
    Got a question regarding the material-components-android-compose-theme-adapter. The latest stable release 1.1.17 targets Compose 1.3.0-beta01. This does not follow the same structure that accompanist does, which supports only stable compose releases on stable accompanist release, beta compose on accompanist beta and so on. So this means that if we bump to this latest, we’re then transitively depending on the beta version of the compose non compiler libraries. Does this have any implications regarding our running code? From what I understand, if we don’t define some dep explicitly, the transitive dep will take over and gradle will pick the latest version of it. If we do have it defined explicitly I am not sure what it will pick if the transitive is 1.3-beta and ours is 1.2.1. Is this something I should even be worried about in any way? Some help here would be much appreciated.
    c
    n
    • 3
    • 7
  • l

    Loney Chou

    08/29/2022, 4:04 PM
    Hello! I want to make a decay animation whose velocity can be changed by user input (say every time user press a button the velocity goes 50f higher from current velocity). How to do that?
    z
    • 2
    • 1
  • l

    Lukasz Kalnik

    08/29/2022, 5:12 PM
    I want to hide the bottom sheet from inside a ViewModel (after a backend call succeeded). To do this, I need to emit a
    StateFlow
    from the ViewModel which contains a boolean property
    showBottomSheet
    . In my screen's composable, I can then remember (and reinitialize) the bottom sheet state like this:
    val modalBottomSheetState = rememberModalBottomSheetState(if (screenState.showBottomSheet) Expanded else Hidden)
    That takes care of hiding the bottom sheet. But how do I keep the
    showBottomSheet
    state in the ViewModel synchronized with the composable, when e.g. the user swipes down the bottom sheet? For this I included a callback in the composable:
    onBottomSheetDismissed
    . I called this callback in the
    confirmStateChange
    lambda parameter of `rememberModalBottomSheetState()`:
    // Composable
    
    val modalBottomSheetState = rememberModalBottomSheetState(
        initialValue = if (screenState.showBottomSheet) Expanded else Hidden,
        confirmStateChange = {
            onBottomSheetDismissed()
            true
        }
    )
    
    // ViewModel
    
    val screenState: StateFlow<ScreenState> = _screenState.asStateFlow()
    private val _screenState: MutableStateFlow<ScreenState>
    
    fun onBottomSheetDismissed() {
        _screenState.update { it.copy(showBottomSheet = false) }
    }
    But it appears that this callback is called very early in the dragging process, and my
    showBottomSheet
    variable in the ViewModel gets reset to
    false
    as soon as the user even drags the bottom sheet one pixel down and the bottom sheet immediately disappears (see video in thread) Is there a better way to handle opening/closing the bottom sheet from a viewmodel and keeping the state synchronized between the two?
    o
    • 2
    • 18
  • p

    Paul Woitaschek

    08/29/2022, 6:07 PM
    Is there any documentation on testing non-ui composable code?
    h
    • 2
    • 3
  • l

    Lucas Mo

    08/29/2022, 6:10 PM
    Hey guys! I have an app whose Composables use the system's default font family (
    FontFamily.Default
    ), but when I change the system's font, it is not updated until I clear the app's data. Is there any way to "force" it to update?
    s
    c
    • 3
    • 2
  • l

    Landry Norris

    08/29/2022, 7:48 PM
    Does Compose have a Modifier that is equivalent to SwiftUI’s id? I have a part of my app that renders pixel data into an IntArray, and I use nativeCanvas to render this to a composable. I don’t want to have to re-allocate this array every time it re-renders, but I do have a variable that I can guarantee will change if the pixels change. I would like changes in this variable to cause recomposition of my Canvas. I know that I can just to a meaningless read of the variable, but I’d like something more clear.
    r
    z
    • 3
    • 13
  • r

    Radoslaw Juszczyk

    08/29/2022, 8:13 PM
    Hey guys, Is there a way to set a pivot point / anchor for
    Modifier.scale(0.5f)
    ?
    z
    • 2
    • 2
  • a

    adjpd

    08/29/2022, 8:20 PM
    Has anyone implemented iOS's overscroll feature, and not just in the latest version of Android, in Compose? It seems like it'd be possible
  • k

    KotlinLeaner

    08/29/2022, 8:25 PM
    I want to change background color when user press on button. When I tried some piece of code it showing my some shadow color. I don't understand. Can someone guide me on this.
    • 1
    • 3
  • j

    Jaime

    08/30/2022, 12:38 AM
    Hello everyone, I am using accompanist.navigation but I have the following exception when the app is just starting Version 0.26.0-alpha Compose 1.3.0-alpha02
    • 1
    • 1
  • l

    Lisandro Di Meo

    08/30/2022, 1:25 AM
    Since AndroidComposeView is implemented using a ViewGroup, is it possible to access to its children (composeviews) as they were normal android views? (I know there is a specific way to test Compose views, but I'd like to know how these compose nodes are implemented).
    j
    • 2
    • 5
  • k

    Kyant

    08/30/2022, 4:33 AM
    Hi everyone. I created a color palette library that allows you to customize and extend M3 ColorScheme in Compose, supporting Android 5.0+. https://github.com/Kyant0/Monet Just provide a key color, it will generate tonal palettes with several styles. You can map the generated palettes to M3's by using
    dynamicColorScheme()
    , and set it to
    MaterialTheme
    . (Don't forget to provide
    LocalTonalPalettes
    first.) You can also get a dynamic color by using
    40.a1 withNight 80.a1
    (100 means white, 0 means black), this is very brief. There's a demo you can play with.
  • c

    Cristina Uroz

    08/30/2022, 9:02 AM
    Hello everyone! Does anyone have an example of the use of Osmdroid with compose?
    j
    • 2
    • 1
  • m

    Mustafa İsmail Alkan

    08/30/2022, 10:13 AM
    Hello, I'm trying to implement full screen ModalBottomSheetLayout with TopAppBar and I wonder how other people implemented.
    • 1
    • 1
  • o

    oday

    08/30/2022, 11:01 AM
    got a question about tests Is this view test https://hastebin.com/uxojevukos.kotlin equivalent to this compose test? https://hastebin.com/iwoderazid.kotlin
    • 1
    • 1
Powered by Linen
Title
o

oday

08/30/2022, 11:01 AM
got a question about tests Is this view test https://hastebin.com/uxojevukos.kotlin equivalent to this compose test? https://hastebin.com/iwoderazid.kotlin
I want to start an activity with an argument, which will open a certain fragment for me, and there i check if the title is what i expect
View count: 12