https://kotlinlang.org logo
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
  • s

    Stephan Schuster

    04/13/2022, 10:16 AM
    Is there a way to create/load
    androidx.compose.ui.text.font.FontFamily
    from a font family defined in XML?
    ➕ 1
    c
    s
    • 3
    • 3
  • j

    James Black

    04/13/2022, 6:28 PM
    How do I get the text to be inline with the switch?
    Row(horizontalArrangement = Arrangement.Center) {
        Switch(
            checked = checkedState.value[index],
            onCheckedChange = { ... }
        )
        Text(s.clothingLabel, style = MaterialTheme.typography.h6)
    }
    I am using compose 1.2.0-alpha07
    k
    e
    n
    • 4
    • 4
  • t

    Trey

    04/13/2022, 7:34 PM
    Can anybody point me to some docs or source that shows the best practice for a real app that contains more than just one ViewModel? I'm trying to understand the best way to configure the app so that the state controls the page shown and each page has its own view model that is only created when the page loads. I can only find simple examples that gloss over that type of complexity.
    i
    • 2
    • 1
  • h

    harry.singh

    04/13/2022, 7:45 PM
    Hey all! I've a
    HorizontalPager
    inside a scrollable
    Column
    and the pages in the pager are of different height. Because of height differences, the shorter page have compensating whitespace at the bottom to match size of the tallest page(Right now I only have 2 pages). Is there a way to have the
    HorizontalPager
    wrap it's height to the height of the currently selected page?
    • 1
    • 1
  • t

    Travis

    04/13/2022, 8:10 PM
    Anybody here know an efficient way to animate LazyRow's horizontalArrangement property? I have something along the lines of
    val animatedSpacingScale by transition.animateFloat(label = "scale") { state ->
      when(state) {
        LargeSpacing -> 10f
        NormalSpacing -> 1f
      }
    }
    LazyRow(
      horizontalArrangement = Arrangement.spacedBy(initialMargin * animatedSpacingScale),
    ) {
      items(viewModel.urls) {
        MyCustomImageWhatever(
          url = it,
          modifier = Modifier.height(90.dp)
              .aspectRatio(1f, matchHeightConstraintsFirst = true),
        )
      }
    }
    and it works, but it causes recomposition of the list at every animation step. Is there a nice clean way to get this done without all that recomposition or am I fundamentally misunderstanding something?
    c
    d
    • 3
    • 2
  • c

    Colton Idle

    04/13/2022, 9:42 PM
    Maybe this is a simple question but is
    android.useAndroidX=true
    needed in a pure compose android app?
    t
    • 2
    • 2
  • l

    Lilly

    04/14/2022, 12:07 AM
    Is it possible to place 2 children as normal at the top and one child at the bottom in a
    Column
    ? For example:
    Column(modifier = Modifier.fillMaxWidth().height(80.dp).padding(12.dp)) {
      Text("Text1")
      Text("Text2")
    
      // At bottom
      Button(onClick = {}) {
        Text("Click")
      }
    }
    c
    t
    c
    • 4
    • 58
  • v

    Valentin Gusselnikov

    04/14/2022, 1:29 PM
    Hi! How can I detect if Composable element is visible on the screen or vice versa, without too much calculations? I want to hide the top
    Image
    if the
    Button
    (which is placed at the end) is not visible and user have to scroll for it. Root Composable is
    ConstraintLayout
    🙏 1
    • 1
    • 1
  • s

    Slackbot

    04/14/2022, 2:02 PM
    This message was deleted.
    :thread-please: 4
    c
    t
    • 3
    • 2
  • t

    the great warrior

    04/14/2022, 3:45 PM
    Hi guys I have Transition that manages AnimatedVisibility of the buttons and runs them simultaneously if isStartButtonVisible changes, but the problem is that isStartButtonVisible state is not saved and that makes AnimatedVisibility of the buttons also change Go to reply if you wanna see the full code
    d
    • 2
    • 3
  • d

    dimsuz

    04/14/2022, 4:00 PM
    If I have a vector image resource which has 3 colors, can I somehow replace each of those? Perhaps by constructing some smart
    ColorFilter
    ?
    Image(
      painter = painterResource(R.drawable.multi_color_image),
      colorFilter = buildColorMatrix(
        replacements = mapOf(Color.White to Color.Red, Color.Black to Color.Blue)
      )
    )
    
    fun buildColorMatrix(replacements: Map<Color, Color): ColorMatrix {
      // ???
    }
    My color-space-fu is not strong enough. Or not possible?
    z
    • 2
    • 2
  • n

    nuhkoca

    04/14/2022, 5:10 PM
    Hello, how can I provide 2 different ripple colors depending on the actual theme? I tried to implement my own RippleTheme but didn’t understand how it works
    private object MyRipple : RippleTheme {
        @Composable
        override fun defaultColor(): Color = TRTheme.colors.secondaryBlue1
    
        @Composable
        override fun rippleAlpha(): RippleAlpha = RippleTheme.defaultRippleAlpha(
            Color.Black,
            lightTheme = !isSystemInDarkTheme()
        )
    }
    ✅ 1
    ➕ 1
    l
    • 2
    • 7
  • d

    dazza5000

    04/14/2022, 5:18 PM
    Does anyone have a suggestions on how I could make this a reusable component / modifier?
    a
    k
    • 3
    • 22
  • b

    brabo-hi

    04/14/2022, 5:49 PM
    Hi all, can compose navigation handle
    Android App Links
    🙌 1
    i
    • 2
    • 2
  • b

    brabo-hi

    04/14/2022, 6:30 PM
    i am running into this issue
    This version (1.2.0-alpha07) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.6.20
    even though i have
    org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10
    k
    s
    • 3
    • 3
  • c

    Colton Idle

    04/14/2022, 10:49 PM
    I know this was discussed a bit before (i remember talking about it in the dev preview) but did anything ever update from what the default theme should be for a compose only app? I currently use
    <style name="Theme.My.App" parent="android:Theme.Material.NoActionBar" />
    I think Chris Banes was talking about this sort of stuff last, but yeah. Just curious if theres a way to use non-appcompat theme (so no appcompat dependency) but have a DayNight theme? because I don't want to bring in appcompat, but it looks like Theme.Material.* doesn't have any daynight variation. I think
    a
    c
    a
    • 4
    • 29
  • g

    Gumiku

    04/15/2022, 4:27 AM
    anyone use
    ideavim
    with
    android studio
    here? do you know how can I disable the auto build? don't know why it always trigger a auto build..😂
    z
    • 2
    • 2
  • i

    ildar.i [Android]

    04/15/2022, 11:06 AM
    we experience a lot of lag when LazyColumn adds a new portion of composables. What can we do to mitigate it? it’s a calendar with a lot of distinct Text()’s each month
    c
    c
    +2
    • 5
    • 7
  • m

    Manideep Polireddi

    04/15/2022, 2:07 PM
    Hi all, it'd be great if some of you could proofread my article https://okmanideep.github.io/understanding-composition-and-side-effects It tries to shed some light on the order of execution of @Composable functions and Side Effects
    a
    t
    • 3
    • 25
  • a

    allan.conda

    04/15/2022, 5:05 PM
    Struggling with multiple backstacks with compose routes... What would be the correct way to navigate to a destination that is in another tab? Let’s say A, J, X is the bottom bar top-level destinations, and this is the graph:
    A -> B -> C
    J -> K -> L
    X -> Y -> Z
    If app is in J, then it wants to go navigate to Y, how do I navigate to Y correctly? I just call
    navController.navigate("Y")
    , but then the bottom bar now behaves weirdly, tapping the J bottom bar does nothing. The bottom bar is showing because it’s logic for visibility is
    currentDestination.hierarchy.any { it.route in bottomDestinations }
    based on official docs and samples. Is there a better way?
    i
    • 2
    • 15
  • t

    the great warrior

    04/15/2022, 5:18 PM
    if I press the start button isStartButtonVisible state is changed from true to false and when I go to another tab compose doesn't remember that. go to reply if you want to see the full code
    device-2022-04-15-170143.mp4
    i
    • 2
    • 3
  • c

    colintheshots

    04/15/2022, 9:20 PM
    I’m trying to get text to enter a currency-specific textfield from right to left with two decimal places and a locale-dependent DecimalFormatSymbol. Essentially, this is what Paypal/Venmo and others do and it’s become a pattern many people are familiar with. Obviously, I’ll need to swap the order for RTL languages. I’ve got the formatting working, but the text still enters from left to right. Does anyone have any tips to change the order the text is entered? Has anyone built a UI element like this in Compose already?
    e
    s
    • 3
    • 21
  • l

    Lilly

    04/15/2022, 10:03 PM
    Would you collect a Flow (not StateFlow) in a composable or collect it in viewmodel and expose it as snapshot (MutableState) field? e.g. your business logic emits a constant flow of progress values to show a ProgressIndicator in UI
    m
    • 2
    • 4
  • t

    Trey

    04/16/2022, 3:13 PM
    I've run into an issue with compose 1.1.1 and kotlin 1.6.20 not being supported. It appears to be failing on purpose because compose is checking the kotlin version. It recommends 1.6.10 and suggests overriding suppressKotlinVersionCompatibilityCheck, but I can't get that to work because of changes in Android Studio. Has anybody run into this with 1.6.20 and most importantly, do you have a work around?
    k
    a
    +2
    • 5
    • 10
  • a

    allan.conda

    04/16/2022, 3:34 PM
    Is there a way yet to correctly prevent re-initialization of an expensive AndroidView in compose? Such as for these situations: • LazyColumn/LazyVerticalPager with AndroidView (say with ExoPlayer Views) ◦ Seems weird that it is not able to recycle Android View instances like a RecyclerView, it seems to expensive when your items have AndroidView. ◦ Would I need to implement my own recycled view pool? • Switching destinations in the NavHost (Say Google Maps View with other destinations) I tried saving the MapsView instance in a singleton in the official maps-compose sample, though it’s still not seamless like in the Production Google Maps App. [Demo in Thread]
    a
    z
    • 3
    • 7
  • l

    Leander Behr

    04/16/2022, 5:03 PM
    ah so after some testing I see that Compose must be doing some kind of analysis to determine where a property is used in the tree
    c
    z
    • 3
    • 2
  • v

    Vinay Gaba

    04/16/2022, 5:04 PM
    Wrote an article about how you can debug recompositions in Jetpack Compose - https://www.jetpackcompose.app/articles/how-can-I-debug-recompositions-in-jetpack-compose
    🙌 4
    :thank-you: 10
    🙌🏼 1
    🎉 2
    l
    • 2
    • 3
  • a

    aniruddha dhamal

    04/16/2022, 5:10 PM
    Hi, Facing issue with loading new images in
    LazyColumn
    . Existing image shows until new image is available. It's using Coil's
    ImageLoader
    and
    produceState
    . Details in the 🧵
    AddNewImage.mov
    c
    a
    • 3
    • 6
  • s

    Slackbot

    04/16/2022, 8:15 PM
    This message was deleted.
    :thread-please: 6
    j
    i
    • 3
    • 2
  • m

    martmists

    04/16/2022, 10:17 PM
    Is there a multiplatform solution to playing audio or would I need to make platform-specific implementations?
    s
    • 2
    • 2
Powered by Linen
Title
m

martmists

04/16/2022, 10:17 PM
Is there a multiplatform solution to playing audio or would I need to make platform-specific implementations?
s

smallshen

04/17/2022, 12:08 AM
https://github.com/korlibs/korau
m

martmists

04/17/2022, 1:49 PM
This one seems to only support very few formats though, isn't there something like a multiplatform exoplayer? I mainly need support for Webm/Opus and M4A/AAC
View count: 4