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

    orangy

    07/09/2022, 8:43 PM
    I seem to get lost with
    derivedStateOf
    or maybe there is a bug. I have remembered derived state which basically gets parameter of a composable function (AnnotatedText) and produces a value from it, some other local mutable state (hover state) and some composition local (theme holding colors). The problem is that the derived state doesn’t produce change when composition local changes. If I remove
    remember
    it obviously recomposes, new instance is created and it works fine. But that means that it will recompose and recalculate the value whenever anything changes, which is rather expensive in my case. Do I miss something?
    t
    d
    z
    • 4
    • 11
  • j

    Jitendra

    07/10/2022, 1:32 AM
    How can I use textClock widget in compose, apart of using androidView
    a
    • 2
    • 1
  • m

    Marcin Wisniowski

    07/10/2022, 2:03 PM
    How do you generate a color scheme for Material 3? The Material Theme Builder web tool is linked in Material docs, but it doesn't work (seems abandoned, and GitHub issues saying it doesn't work are unresolved since 2021), so I'm not sure what's the current solution.
  • i

    itnoles

    07/10/2022, 4:10 PM
    https://github.com/android/nowinandroid/blob/main/core-ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt#L228 Is this is preferred solutions for date formatter?
  • a

    Andrei Kovalev

    07/10/2022, 4:36 PM
    Hi folks, we're happy to share something we've been working on for a while at Bumble – we just recently released the first version of https://github.com/bumble-tech/appyx. It comes with the ability to wrap your composables to components with a lifecycle, and have powerful navigation engines for them with custom states and transitions. Project page and documentation can be found at https://bumble-tech.github.io/appyx/, it demonstrates the above with some nice visual examples. Give it a try and tell us what you think 🙂
    👀 3
    👍 4
    m
    z
    +2
    • 5
    • 7
  • s

    Slackbot

    07/10/2022, 7:55 PM
    This message was deleted.
    d
    s
    • 3
    • 7
  • c

    Colton Idle

    07/11/2022, 12:30 AM
    Regarding
    collectAsState
    is it more appropriate to have 1️⃣
    val user = appStateHolder.currentUser.collectAsState().value
    or 2️⃣
    val user = appStateHolder.currentUser.collectAsState()
    a
    i
    • 3
    • 9
  • v

    Vaios Tsitsonis

    07/11/2022, 8:40 AM
    Hello! I have a problem and I need some help. While running android tests in a project i randomly get the following error:
    No compose hierarchies found in the app. Possible reasons include: (1) the Activity that calls setContent did not launch; (2) setContent was not called; (3) setContent was called before the ComposeTestRule ran. If setContent is called by the Activity, make sure the Activity is launched after the ComposeTestRule runs
    With the term randomly, I mean different tests every time. I have defined my rules like that:
    @get:Rule(order = 0)
    var hiltRule = HiltAndroidRule(this)
    
    @get:Rule(order = 1)
    val composeTestRule = createEmptyComposeRule()
    
    @get:Rule(order = 2)
    val activityTestRule = createActivityRule<MainActivity>()
    Is there something wrong???
    ➕ 1
  • a

    Alex

    07/11/2022, 12:08 PM
    Instead of annotating a
    List
    parameter as
    @Stable
    , could I also just use an
    ImmutableList
    from https://github.com/Kotlin/kotlinx.collections.immutable ? Will Jetpack Compose understand?
    s
    e
    p
    • 4
    • 5
  • l

    Luke

    07/11/2022, 3:25 PM
    Is there a reason why
    Rect.contains(Offset)
    is not marked as
    operator
    ? It would be nice to be able to use the
    in
    keyword
    a
    z
    +2
    • 5
    • 6
  • z

    ziv kesten

    07/11/2022, 3:59 PM
    How would i create a
    Card
    with these gradient?,
    card
    background color only responds to
    backgroundColor
    , using modifer like this:
    .background(brush = Brush.linearGradient(
                            colors = listOf(
                                colorResource(id = R.color.lemonade_pink),
                                Color.White.copy(alpha = 0.1f)),
                            start = Offset(0f, Float.POSITIVE_INFINITY),
                            end = Offset(Float.POSITIVE_INFINITY, 0f)
                        )
                    )
  • k

    kotlinforandroid

    07/11/2022, 4:07 PM
    I have a compose app with edge to edge content that also uses
    ModalBottomSheetLayout
    . The problem I am facing is that the BottomSheets also draw under the statusbar. It looks weird when the sheet is not fully expanded since the sheet has a lot of padding visible at the top. How can I prevent this?
    t
    • 2
    • 1
  • m

    mattinger

    07/11/2022, 4:36 PM
    Does anyone know if there’s a way to intercept the dismiss operation of the scrim was clicked? I don’t want to stop it from dismission, but i do want to log that it occurred. I could use the confirmStateChange as that does get called when the scrim is clicked, and appears to not be called if i programatically close using the .hide() function. But that seems odd to put it in the state.
    Scrim(
                    color = scrimColor,
                    onDismiss = {
                        if (sheetState.confirmStateChange(Hidden)) {
                            scope.launch { sheetState.hide() }
                        }
                    },
                    visible = sheetState.targetValue != Hidden
                )
    As a side question, under what other circumstances would confirmStateChange be called? I see a bunch of stuff in the semantics area, but on testing, i don’t see confirmStateChange called if i manually call hide().
    t
    • 2
    • 1
  • c

    Colton Idle

    07/11/2022, 5:09 PM
    We're trying to enforce that everyone uses our predefined text styles via a lint rule (that warns if you use a Text composable) and by having this MyText defined.
    @Composable
    fun MyText(text: String, style:MyTextStyle, color: Color) {
      val selectedStyle = when (style) {
        MyTextStyle.H1 -> MyTypography.H1 //maps enum to TextStyle
        MyTextStyle.H2 -> MyTypography.H2
      }
      Text(text = text, color = color, style = selectedStyle)
    }
    Does this seem like a bad idea to anyone? The map of an enum to a text style feels off, but I think this would get the job done.
    f
    z
    • 3
    • 2
  • l

    Lisandro Di Meo

    07/11/2022, 6:49 PM
    Hello, how can I avoid a composable begin drawn outside scope? I'd like to do something like the picture with blue background.
    c
    e
    • 3
    • 4
  • b

    Brendan Campbell-hartzell

    07/11/2022, 8:50 PM
    I'm using a BasicTextField with an annotated string to make a rudimentary rich text editor. However, the styles keep getting removed whenever the value is updated via the onValueChange callback. Am I missing something about the functionality of the BasicTextField? Code in thread.
    a
    • 2
    • 5
  • z

    zsperske

    07/11/2022, 8:54 PM
    Is it possible to convert a
    SpannableString
    to an
    AnnotatedString
    ?
    👍 1
  • t

    Travis Griggs

    07/11/2022, 9:02 PM
    I'm trying to figure out the maze of permissions requesting for BLEScanning, but in a Compose app. I'm struggling with how to architect this. When I press my "scan" button, should I make that fire a method on my Activity? or my ViewModel? Is the dance one does to check/request permissions done the same as it always has been? or are their newer composey ways to do that part?
    m
    s
    s
    • 4
    • 13
  • t

    Travis Griggs

    07/11/2022, 11:39 PM
    When I need to interact with an Android peripheral (like Camera, or BLE. etc) does that type of code go in one's ViewModel, or stay in the Activity/Fragment (which then feeds the data to the ViewModel)?
  • n

    Ngọc Nguyên Nguyễn

    07/12/2022, 8:13 AM
    Hi every one!! I have a list with items = { ParentClass(val child1: Child1Class, val child2: Child2Class, val child3: Child3Class), … } . All class are Immutable. Can I update _viewstate just recompose one of childClass, ignore to recompose all ParentClass??
    s
    • 2
    • 2
  • t

    Tgo1014

    07/12/2022, 9:39 AM
    is there a way to tint a drawable with a gradient?
    l
    • 2
    • 3
  • f

    Frank van der Laan

    07/12/2022, 9:46 AM
    Can we use separate preview resources? Let's say a different strings file for example?
  • m

    miqbaldc

    07/12/2022, 9:48 AM
    Does anyone has references to build this similar UI in Compose?
    v
    • 2
    • 1
  • v

    Vahalaru

    07/12/2022, 11:45 AM
    Good morning all, so I have done some research and don't find any reference to what I'm looking for. I have a company's logo in an image. In trying to set the image as the background for topbar instead of a color. Such as
    c
    • 2
    • 4
  • a

    Alejandro Rios

    07/12/2022, 1:27 PM
    This is really cool, nice one @Halil Ozercan: https://twitter.com/astamatok/status/1546579778400034817
    👏🏻 1
    :thank-you: 4
    😮 4
    👏 6
    t
    • 2
    • 1
  • s

    Slackbot

    07/12/2022, 1:55 PM
    This message was deleted.
    a
    v
    • 3
    • 3
  • d

    Dmitry Berdnikov

    07/12/2022, 2:33 PM
    Hello there! I have search screen where there is LazyColumn with AnimatedVisibility wrapped items to have addition animation. Here is the thing: the search result can be huge regarding items count and I faced that items continuously played enter animation during scroll. But I only need item to be animated which are visible to user before scroll How can I solve this?
  • n

    nuhkoca

    07/12/2022, 6:12 PM
    Helli, is there a good Compose supported chart library except MPChart?
    c
    s
    • 3
    • 3
  • a

    agrosner

    07/12/2022, 7:43 PM
    hey quick question on
    java.lang.IllegalArgumentException: LazyHorizontalGrid's height should be bound by parent.
    We started receiving this when we moved to the standard
    LazyHorizontalGrid
    implementation in 1.2.0 (we're on rc01). This lives within a
    LazyVerticalGrid
    (full span). Does this mean we need to fix the height of the grid within this container (no way for the content to speak to its size)
    s
    • 2
    • 7
  • j

    Jonas

    07/13/2022, 5:37 AM
    A11y semantics heading - scrollable - constraint layout bug We currently tried to mark headings in multiple of our apps and noticed that it strangely doesn’t work in some cases. After days of debugging we pinned it down to following constellations.
    Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
        ConstraintLayout {
            Text(
                text = "this should be a heading",
                modifier = Modifier.semantics { heading() })
        }
    }
    As soon as something is wrapped in a scrollable container (also tried with LazyLists) and a ConstraintLayout TalkBack does not announce that text as heading. Apart from the semantic tree looking correct (see thread). Anyone an idea what could cause this? Should we file a bug report?
    • 1
    • 2
Powered by Linen
Title
j

Jonas

07/13/2022, 5:37 AM
A11y semantics heading - scrollable - constraint layout bug We currently tried to mark headings in multiple of our apps and noticed that it strangely doesn’t work in some cases. After days of debugging we pinned it down to following constellations.
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
    ConstraintLayout {
        Text(
            text = "this should be a heading",
            modifier = Modifier.semantics { heading() })
    }
}
As soon as something is wrapped in a scrollable container (also tried with LazyLists) and a ConstraintLayout TalkBack does not announce that text as heading. Apart from the semantic tree looking correct (see thread). Anyone an idea what could cause this? Should we file a bug report?
Printing with useUnmergedTree = 'false'
Node #1 at (l=0.0, t=56.0, r=259.0, b=89.0)px
 |-Node #2 at (l=0.0, t=56.0, r=259.0, b=89.0)px
   VerticalScrollAxisRange = 'ScrollAxisRange(value=0.0, maxValue=0.0, reverseScrolling=false)'
   Actions = [ScrollBy]
    |-Node #3 at (l=0.0, t=56.0, r=259.0, b=89.0)px
      DesignInfoProvider = 'androidx.constraintlayout.compose.Measurer@9cb80f4'
       |-Node #4 at (l=0.0, t=56.0, r=259.0, b=89.0)px
         Text = '[this should be a heading]'
         [Heading]
         Actions = [GetTextLayoutResult]
I created an issue for that: https://issuetracker.google.com/issues/239549290
View count: 6