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

    Afzal Najam

    11/24/2022, 10:48 PM
    For recomposition purposes, does wrapping anything, even unstable types, in
    mutableStateOf
    make it stable as long as it’s only unwrapped at the end? If not, why does Compose Metrics say that
    State<Something>
    is stable? Does using
    referentialEqualityPolicy
    make a difference in this case.
  • k

    K Merle

    11/25/2022, 7:08 AM
    I am getting a following error message during the UI tests when I test it with
    onNodeWithText
    , but I'm not sure what's causing 2 nodes to be found. 🧵
    s
    • 2
    • 5
  • k

    KotlinLeaner

    11/25/2022, 11:54 AM
    Hi want to know how can we return
    Column/Row
    through lamda function in jetpack compose. I tried something but it giving me error. PairContent
    @Composable
    fun PairContent(
        bluetoothEnable: (ColumnScope) -> Unit,
    ) {
        AnimatedVisibility(visible = true) {
            Scaffold {
                Column { columnScope ->
                    bluetoothEnable(columnScope)
                }
            }
        }
    }
    p
    • 2
    • 8
  • s

    ste

    11/25/2022, 1:56 PM
    There's no way to un-apply
    Modifier.clipScrollableContainer
    to
    LazyList
    , there is? ._.
  • p

    PHondogo

    11/25/2022, 6:34 PM
    Hello! Is it possible to implement in compose soft keyboard and integrate it? If yes, how to do it?
    d
    • 2
    • 1
  • d

    Daniele Segato

    11/25/2022, 6:50 PM
    I'm trying to make a complex
    Layout
    with custom measurement and placement. I want to animate elements inside it, specifically when a parameter change I want one item to move and scale. I first approached this like this:
    val dynamicSize = animateFloatAsState(
            targetValue = if (condition) .3f else 1f
        )
        Layout(
            content = {
               Box(
                   modifier = Modifier
                       .fillMaxSize(dynamicSize.value)
               )
               // ...
    and than I kept the size to full inside my measurement... But now I actually need to decide the scaling in my layout measure logic. Should I remove the
    fillMaxSize()
    , have an
    animateFloatAsState()
    outside the
    Layout
    and use the
    0f
    -->
    1f
    inside the measure block to control the size with the constraints? Is this an efficient way of handling animations with
    Layout
    ? I'm worried that i can become very complex in this layout to work with all the possibles options for animations. I'm open to suggestions / code examples / anything that can show me how people handle this kind of things. Thanks.
    d
    • 2
    • 3
  • z

    zsperske

    11/25/2022, 7:16 PM
    I have a class which extends
    AbstractComposeView
    that wraps our Button component, to allow our legacy XML pages to make use of the component. In our existing UI tests we have espresso calls like
    onView(withId(id)).perform(click())
    . When using this method on the Compose view, no click event is triggered. Has anyone else run into this/know of a fix?
    l
    d
    • 3
    • 13
  • p

    PHondogo

    11/26/2022, 12:44 PM
    How to make element clickable but without requesting focus on click?
    m
    • 2
    • 1
  • r

    robercoding

    11/26/2022, 1:28 PM
    Hey I have a question for the compose experts 😁 I'm having unwanted recomposition when using
    clickable
    or any other Modifier extension that implements
    composed
    under the hood, so I dived a bit into
    composed
    extension. From my own investigation, it seems that the root cause is that is creating a new
    ComposedModifier
    each time the parent scope gets invalidated, so that would mean that any Composable (i.e Text) that is implementing something like
    Modifier.clickable { }
    won't be skipped if the parent scope gets invalidated But then it seems that there's an open issue tracker about this: https://issuetracker.google.com/issues/241154852 In the issue tracker it states that: Returning values from Composable functions are the cause of recomposition Sadly I couldn't reproduce it by making an extension that returns value (Int, string) or even a Modifier. 🤔 The only way I was able reproduce the issue is by having a custom class that inherits from
    Modifier.Element
    and this is creating a instance each time
    . (If it's an
    object
    type it doesn't recompose
    ) So now I'm a bit bugged, I'd like to know what's exactly causing the Composable that implements
    composed
    to be recomposed when the parent scope gets invalidated?
    a
    z
    • 3
    • 7
  • v

    Vikas Singh

    11/26/2022, 4:40 PM
    I am using a horizontal pager with negative itemspacing value because of which the 2nd item is getting overlapped on the 1st item with a higher zIndex, Ideally the 2nd item should always have a less zIndex than the first one. Did anyone else face this ?
  • m

    miqbaldc

    11/28/2022, 2:13 AM
    Folks is there anyone encounter following log:
    Method boolean androidx.compose.runtime.snapshots.SnapshotStateList.conditionalUpdate(kotlin.jvm.functions.Function1) failed lock verification and will run slower.
        Common causes for lock verification issues are non-optimized dex code
        and incorrect proguard optimizations.
    • 1
    • 2
  • a

    Abdul Hafeez Sajid

    11/28/2022, 7:54 AM
    Hi everyone, I am using MotionLayout to animate the font size change on Text but I can’t get it working. Can anyone highlight the issue with the code given in thread. Thanks
    • 1
    • 1
  • a

    Abdulaziz Mohammed

    11/28/2022, 9:48 AM
    I want to migrate my app from xml to compose, how can I do that in right way?
    s
    • 2
    • 2
  • m

    Michal Guspiel

    11/28/2022, 11:34 AM
    Hi I have a screen in which I have several composables, including textField. When the text field is being edited my composables get recomposed even though the input in them doesn’t change and they are “restartable skippable scheme”. I have also plain Text in that screen which gets skipped in recomposition. I’m having hard time to understand, anybody?
    e
    z
    • 3
    • 10
  • m

    Michael Job

    11/28/2022, 12:38 PM
    General design question, but will be implemented with compose. LazyColumn, scrollable. How do you visualize to the user if there is additional content hidden at the bottom, which can be seen if list is scrolled up? Option A) would be to have half an item at the bottom, so the user sees the need to scroll. But with different device sizes, this does not seem a legit way. Option B) to display a scrollbar does not sound very attractive to me. Are there other ideas? How would you do it?
    f
    • 2
    • 1
  • o

    oday

    11/28/2022, 2:38 PM
    got a tricky situation, I would like to set a label for some element to be XYZ
    only
    if its the first time that this composable is being shown if I set
    isFirstTime
    as a Boolean, and I then change the label (which is remembered) then recomposition happens and isFirstTime is initialized again as false and then it repeats and i fall into the
    isFirstTime == false
    condition again if I set
    isFirstTime
    to remember, then changing it to
    true
    after the first time has happened, this will also trigger recomposition and then it automatically falls into the
    isFirstTime
    is true in the same recomposition that just happened
    a
    • 2
    • 3
  • v

    Ville Orkas

    11/28/2022, 3:40 PM
    Has anyone ran in to this issue before? https://issuetracker.google.com/issues/260540794 We are stuck with API level 22 devices and are kinda hoping for a workaround or something like that. On our real project the memory leak is much more severe and it doesn’t take that long to run into an OOM exception when navigating our app.
  • d

    dephinera

    11/28/2022, 8:15 PM
    Anyone using android's paging lib for compose on production? It's been in alpha for quite a while. Can it be considered stable with the only risk of changing the API or does it have bugs and performance issues?
    r
    c
    • 3
    • 5
  • j

    Jasmin Fajkic

    11/28/2022, 9:05 PM
    Is it normal behaviour that my composable function recompose every time when keyboard shows/hide?
    z
    • 2
    • 1
  • c

    Corey

    11/28/2022, 9:06 PM
    Whenever I add a
    AbstractComposeView
    into an existing Fragment to continuously integrate compose into an existing codebase, I have a memory leak 💥. Tho I use
    setCompositionStrategy
    for this View the issue remains. Does anyone knows if this is an existing issue in Compose UI or am I missing something?
    c
    • 2
    • 2
  • z

    Zoltan Demant

    11/29/2022, 10:38 AM
    Is there a space for sharing apps that are published & entirely compose based yet (not necessarily open sourced)? If not, can we have one? 🤓 Having gone to the Tivi app more than a dozen times myself in the past - I think this could be a good way to showcase what [design, performance, ?] you can acheive with compose, and just get people even more inspired overall! 🌟
    l
    • 2
    • 2
  • c

    Colton Idle

    11/29/2022, 4:01 PM
    WHAT IS THIS? paparazzi alternative? https://twitter.com/ppvi/status/1597608519876116482
    j
    m
    +2
    • 5
    • 8
  • l

    Lisandro Di Meo

    11/29/2022, 7:30 PM
    Hi, I'm trying to share a viewmodel between two composables (from A to B). After A made some changes, when navigating to B, retrieving the viewmodel using
    viewModel(
        viewModelStoreOwner = viewModelStoreOwner, ...
    )
    correctly fetches the viewmodel, but the changes made on A now are lost. Am I missing something doing this?
  • a

    Android75

    11/29/2022, 7:32 PM
    Very simple question. Dashboard screen has a Text, viewModel get data from db and so change string in Text.
    @Composable
    fun DashBoardScreen(viewModel: DashBoardViewModel) {
    
        var dashBoardState = viewModel.uiState.collectAsState().value
        Text(text = "Title ${dashBoardState.title}" )
    viewModel.loadData()
    
    // ViewModel
    val uiState = MutableStateFlow(DashboardState(false))
    
       private fun loadData() {
         uiState.value = uiState.value.copy(
                title = "Text Changed" )
        }
    i don’t know why Text doesn’t change string…
    l
    d
    z
    • 4
    • 16
  • u

    ursus

    11/29/2022, 8:58 PM
    Is it just me or do
    animateItemPlacement
    insert the item immediately and then pushes the list down? Is it possible to get what recycler view did? i.e. push the list down, then fade in the new item
  • a

    Andrew Clunis

    11/29/2022, 9:18 PM
    Hi, I have a question about the support git repo where the various Compose libraries live. https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-main/compose/ While I see many tags on it for Android releases among other things, I don't see tags for the releases of the Compose libraries themselves. For example, if I want to see the source of compose.ui 1.2.1, how do I find out which git commit ID I should check out? Cheers and thank you 🙂
    i
    • 2
    • 7
  • l

    Luis Daivid

    11/30/2022, 1:41 AM
    Hi. How can I implement this button? I can implement the gradient of the button, but I don’t know how to implement the gradient shadow at the bottom.
    z
    t
    • 3
    • 2
  • a

    AmrJyniat

    11/30/2022, 9:10 AM
    Can I disable the dot in the keyboard when setting the
    keyboardType
    as Number in the TextField?
    g
    j
    • 3
    • 5
  • t

    Tolriq

    11/30/2022, 9:50 AM
    I there a way to avoid StaleObjectException with uiautomator when there's recomposition? I can't trigger any action on anything that is animated. (Needed to build the baseline profiles)
  • a

    Android75

    11/30/2022, 10:37 AM
    I have some problem with lifecycle… When i click button CHANGE title doesn/t change.. and i think.. code is correct.. or not?
    c
    ö
    • 3
    • 9
Powered by Linen
Title
a

Android75

11/30/2022, 10:37 AM
I have some problem with lifecycle… When i click button CHANGE title doesn/t change.. and i think.. code is correct.. or not?
when I turn off the display … after some seconds.. Text change string… it’s crazy
c

Chris Fillmore

11/30/2022, 2:29 PM
Please move your code blocks into the thread, that’s why people are reacting with 🧵
a

Android75

11/30/2022, 4:26 PM
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {

            val navController = rememberNavController()
            MyAppTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colors.background
                ) {
                    NavigationComponent(navController)
                }
            }
        }
    }
}
@Composable
fun NavigationComponent(navController: NavHostController) {
    NavHost(
        navController = navController,
        startDestination = Destination.Dashboard.path
    ) {
        composable(Destination.Dashboard.path) {
            val viewModel: DashBoardViewModel = hiltViewModel()
            DashBoardScreen(viewModel)
        }

    }
}

@Composable
fun DashBoardScreen(viewModel: DashBoardViewModel) {

    val dashBoardState by viewModel.uiState.collectAsState()


    Column(modifier = Modifier.fillMaxSize().background(Color.White)) {
        Text(
            text = "${dashBoardState.title}",
            fontSize = 20.sp,
            color = Color.Black,
            textAlign = TextAlign.Center,
            modifier = Modifier.padding(16.dp)
        )

        Button(onClick = {viewModel.changeTitle()}) {
            Text(
                text = "CHANGE")
        }
    }
}

@HiltViewModel
class DashBoardViewModel @Inject constructor(
) : ViewModel() {


    val uiState = MutableStateFlow(DashboardState(false))


    fun changeTitle() {
        viewModelScope.launch {

            uiState.emit(uiState.value.copy(
                title = "Ciao"

            ))
        }
    }
}

data class DashboardState(
    var isLoading: Boolean = false,
    var title: String = "start"
)
I created a project… https://github.com/GioeleDev95/stateexaple2 it doesn’t work
ö

Ömer Faruk Delibaş

11/30/2022, 5:33 PM
I tried your code and everything is working. You can change
text = "${dashBoardState.title}"
this to
text = dashBoardState.title
. Because it’s already string. And maybe some little improvements for SOLID but apart from that your code is working.
a

Android75

12/01/2022, 7:04 AM
i tried in two smartphone and when tap CHANGE Text has same text “start” and not ciao
ok i understood, if i use “androidx.compose.ui:ui:1.3.1” i have the bug… ui doesn’t change
"androidx.compose.ui:ui:1.3.1" si mandatory to use compile and target 33
ok when i use “androidx.compose.ui:ui:1.3.1” i have bug but with 1.20 works
View count: 9