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

    thelumiereguy

    11/22/2022, 10:19 AM
    1. Does it make sense to have a ‘key’ parameter for an
    item
    in LazyColumn/LazyRow? I know that it helps with
    items
    2. What’s the
    key
    composable for? I saw a code snippet recently where people were wrapping the content with
    key
    composable - inside an
    items
    block. Is there a difference between wrapping with
    key
    vs specifying the key in the items parameter itself. 3. Suppose that we’re sending a state object to a composable, but we’re not reading/getting the value. And now, if the state changes, would this cause a recomposition?
    s
    h
    • 3
    • 3
  • c

    Clemens Kozmich

    11/22/2022, 10:32 AM
    Hey everyone 👋 I am facing a challenge for a custom TopAppBar in Compose and I suppose the ConstraintLayout could help there but I am not sure how it would work. My goal: • Have the navigation icon linked to the start • Have the title centered (between parent.start and parent.end) • Have actions linked to the end (could be zero, one or two icons) My problem: • When I center the title from parent.start to parent.end, long titles would overlap with the action icons. Therefore I would like to keep the title centered, but ellipsize the title when the title.end would overlap with actions.start
    k
    d
    • 3
    • 3
  • m

    myanmarking

    11/22/2022, 11:07 AM
    if i want to use animatedVisibility when some data is not null. Is this safe and correct to do?
    t
    m
    • 3
    • 9
  • d

    dimsuz

    11/22/2022, 11:57 AM
    Do I understand it right that
    LocalMinimumTouchTargetEnforcement
    is working only on material3 components? What is the correct way to add similar functionality to a composable not based on Material component? For example I have custom button of height 32.dp and I want to add invisible touch area around it to make effective touch area of 48.dp height.
    c
    • 2
    • 2
  • p

    PHondogo

    11/22/2022, 12:08 PM
    Hello! What and how is the best way to mark element that has something to scroll? Sometimes it is not clear that there is something more that need to be scrolled to.
    c
    • 2
    • 1
  • h

    harry248

    11/22/2022, 2:48 PM
    Has anyone here migrated from Accompanist SwipeRefresh to the new pullRefresh modifier and suddenly experienced a stuck indicator (like in the video)?
    Screen_Recording_20221122_154110_OCM v200 (223261533)-develop.mp4
    l
    j
    • 3
    • 11
  • l

    Lisandro Di Meo

    11/22/2022, 3:06 PM
    I don't know if this applies here, but if I consume an item from a Flow inside a composable, it will be removed during next recomposition?
    c
    z
    • 3
    • 6
  • t

    Tower Guidev2

    11/22/2022, 3:41 PM
    Good afternoon Composers 😄 can anyone shed some light on where i have wrong? https://stackoverflow.com/questions/74535238/why-isnt-modifier-windowinsetsbottomheightwindowinsets-safedrawing-working-on
    m
    • 2
    • 1
  • a

    Ale Stamato

    11/22/2022, 4:32 PM
    Anyone here using movableContentOf() API ? (https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/runtime/design/movable-content.md) for which usecase? Thanks 🙂
    s
    c
    • 3
    • 3
  • m

    myanmarking

    11/22/2022, 5:17 PM
    i was wondering, what is the best way of tweeking
    animateFloatAsState(
        targetValue = progress.percentage,
        animationSpec = tween(
            durationMillis = 1000,
            easing = LinearEasing
        )
    )
    to support a ‘pause’ state ?
    d
    • 2
    • 2
  • a

    Arjan van Wieringen

    11/22/2022, 7:22 PM
    I am struggling with animating this sidebar. It all works, except I can't get the background to be the full size. Before I started to add animation I used
    IntrinsicSize.Min
    on the Column and used
    fillMaxWidth
    on the contents. But that doesn't work here. Any tips? The gist is here: https://gist.github.com/avwie/9b0ee5f2882e8d26517f4ab7fc2b0408
    Screen Recording 2022-11-22 at 20.18.28.mov
    k
    c
    d
    • 4
    • 13
  • l

    lhwdev

    11/22/2022, 11:42 PM
    Can I use internal pointer logic(something like LayoutNode?) of Compose? Api code emits some marker modifier or node, and I need to check if which one contains clicked node. I'm trying to make Compose extend to window frame in Windows, but I need to check if mouse is on caption, left, right, etc. (HTCAPTION, HTLEFT, HTRIGHT...) I want api to be flexible as much as possible, so fixed option like fixed height of caption is not an option. (If not possible, I have to go with custom rect intersection)
    j
    • 2
    • 3
  • z

    zt

    11/23/2022, 2:23 AM
    I have the following code which I use with media3 for playing videos. The thing I'm wondering is is how can I set it up to display the various states of the player? Such as it being paused, buffering, the elapsed time, etc. I'm not sure if I should use a LaunchedEffect and add the listener there, or if a viewmodel would be better, or maybe even some other way.
    @Composable
    fun Player(
        modifier: Modifier = Modifier,
        player: Player
    ) {
        AndroidView(
            modifier = Modifier
                .aspectRatio(16f / 9f)
                .then(modifier),
            factory = { context ->
                SurfaceView(context)
            },
            update = { surfaceView ->
                player.setVideoSurfaceView(surfaceView)
            }
        )
    }
    p
    y
    • 3
    • 4
  • x

    xxfast

    11/23/2022, 4:52 AM
    is there a way to get the number of columns shown from
    LazyGridState
    , when the columns are set to
    GridCells.Adaptive
    ?
  • e

    eygraber

    11/23/2022, 6:22 AM
    Are there any good videos or posts out there about material 3 and compose?
    z
    • 2
    • 1
  • p

    PHondogo

    11/23/2022, 9:21 AM
    Hello! What is the best way to scroll TextField out of Keyboard on focused? So user can see what he is typing. Better if it can be handled independently of parent element TextField is placed in. Edit: I found bringIntoViewRequester and it is working scrolling out of Keyboard, but Scaffold ButtomBar is still over TextField. How to specify to bringIntoViewRequester to scroll additional BottomBar height?
  • k

    K Merle

    11/23/2022, 12:28 PM
    Regarding the compose screen transition (accompanist lib), is it possible to
    Hold
    a screen?
    i
    • 2
    • 3
  • t

    Taeho Kim

    11/23/2022, 12:56 PM
    Text is always “my age is 0” (never changed). why? it’s bug?
    class MainActivity : ComponentActivity() {
      override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            var age by remember { mutableStateOf(0) }
            val person by remember {
              derivedStateOf { "my age is $age" }
            }
            Column(modifier = Modifier.padding(16.dp))  {
              Button(onClick = {
                age += 1
                Log.e("person", person)
              }) {
    
                Text(text =   person)
              }
              Text(
                text = person)
            }
        }
      }
    }
    h
    z
    +2
    • 5
    • 8
  • d

    davechuks

    11/23/2022, 5:17 PM
    Hello guys. I'm using jetpack compose to build my app and I want to replicate this type of smooth animation anytime I click on an image on screen. I'm not sure how to go about it.
    YouCut_20221123_181548366.mp4
    d
    a
    +2
    • 5
    • 42
  • k

    KotlinLeaner

    11/23/2022, 5:58 PM
    Hi guys, I want to know any api which will not assigne by default value in declaration time. For example
    mutableStateOf("need value in here").
    So anything we can use in compose ?
    c
    • 2
    • 1
  • g

    Gonzalo Renedo

    11/24/2022, 1:38 AM
    Does anyone know why I update my phone to android 12 and now the installSplashScreen works wrong? sometimes it doesn't even come out and it doesn't continue, the app finished as it should...
    j
    c
    • 3
    • 3
  • s

    Shankar Gollakota

    11/24/2022, 3:56 AM
    Hi everyone there a lazyrow is screen A and from screen A i am moving to screen B while coming back to Screen B to Screen A lazyrow in screen A is re rendering ..... How can I avoid the re rendering #compose
  • k

    KotlinLeaner

    11/24/2022, 5:30 AM
    message has been deleted
    p
    c
    • 3
    • 7
  • p

    PHondogo

    11/24/2022, 1:29 PM
    Hello! What is the best way to use draggable modifier? Should and if yes how to pass event to parent scrollable if parent exists at onDelta callback?
  • k

    KotlinLeaner

    11/24/2022, 1:32 PM
    Hi, I have another question why I need to use another
    Column
    inside my
    ColumnScope.ScanDeviceList
    If I removed inside
    Column
    form
    ColumnScope.ScanDeviceList
    my views are misaligned. Is this because of
    AnimatedVisibility
    ? If yes, what is the solution for this? I am using
    AnimatedVisibility
    because I want to give basic animation’s to my view and it also checking the condition. Many thanks
    s
    d
    • 3
    • 9
  • s

    Sudhir Singh Khanger

    11/24/2022, 5:34 PM
    How can I achieve behaviour like this where when images are scrolled the appear edge to edge but there is extra padding in the first item.
    22-11-24-22-58-10_1.mp4
    j
    • 2
    • 1
  • s

    Sean Keane

    11/24/2022, 6:19 PM
    Hi Guys, I've got a question regarding the compose SDK's. Has anyone been able to add them to a KMM project and export the views for an Android App?
    • 1
    • 1
  • g

    Gonzalo Renedo

    11/24/2022, 7:25 PM
    Please someone help me, yesterday I upgraded my phone to android 12 version, since then if I put installSplashScren() or something else before the setContent{} of the MainActivity.kt it fails and doesn't pass to the NavGraph(), when I remove it If it works fine, I don't understand what happens because navGraph doesn't work for me now and any other composable does, and the other way also works for me, removing the installSplashScreen if navGraph() works for me. I don't understand anything...
    s
    c
    • 3
    • 8
  • e

    eygraber

    11/24/2022, 8:31 PM
    If I'm using Jetbrains Compose in a multiplatform project and have an Android target, should I still set
    buildFeatures.compose = true
    in my
    build.gradle.kts
    ? If I don't set it, the IDE doesn't recognize files with compose in them, and doesn't show the preview window. If I do set it the preview window shows, but if I use certain composables the preview (and running the app) breaks with a
    NoSuchMethodError
    . For example if my composable has a
    Text
    , it fails with:
    java.lang.NoSuchMethodError: 'void androidx.compose.material3.TextKt.Text-nZBYWUE(java.lang.String, androidx.compose.ui.Modifier, long, long, androidx.compose.ui.text.font.FontStyle, androidx.compose.ui.text.font.FontWeight, androidx.compose.ui.text.font.FontFamily, long, androidx.compose.ui.text.style.TextDecoration, androidx.compose.ui.text.style.TextAlign, long, int, boolean, int, int, _layoutlib_._internal_.kotlin.jvm.functions.Function1, androidx.compose.ui.text.TextStyle, androidx.compose.runtime.Composer, int, int, int)'
  • d

    Daniel Okanin

    11/24/2022, 9:36 PM
    Hi everyone! What is the best way to check if I still can scroll in LazyList? something that replace the computeVerticalScrollOffset of the recycler view?
    d
    j
    • 3
    • 6
Powered by Linen
Title
d

Daniel Okanin

11/24/2022, 9:36 PM
Hi everyone! What is the best way to check if I still can scroll in LazyList? something that replace the computeVerticalScrollOffset of the recycler view?
d

dewildte

11/24/2022, 10:10 PM
What are you trying to achieve?
I do not know if this is the “best” way but you could check to see if all the items in the list are not visible.
LazyListState#layoutItemInfo
has this infomation.
j

james

11/25/2022, 1:51 AM
if you don’t need to deliver this functionality immediately, you could wait for an upcoming release of Compose, because last week a change was merged which adds
canScrollForward
and
canScrollBackward
properties to ScrollableState.. and it sounds like that’s exactly what you need if you do need to deliver this functionality immediately then just grab the current
value
and the
maxValue
of your scroll state and compare them (if you’re checking for end of list)
d

Daniel Okanin

11/25/2022, 6:46 AM
@dewildte @james I want to achieve the following behavior: By click on the phone back button, I scroll to top if I can, and if not, I dismiss the app
j

james

11/27/2022, 10:04 PM
@Daniel Okanin then you probably want to create your own derived state which checks if there’s room to scroll backward (ie. the scroll state value is >0) so something like:
val scrollState = rememberScrollState()
val canScrollBackward by remember {
    derivedStateOf {
        scrollState.value > 0
    }
}
then in your back handler code you can simply check
if (canScrollBackward) { your scroll-to-top code } else { your dismiss code }
once you get that working you might even want to take it a little further and introduce some threshold, because if the user has scrolled a tiny bit (eg. only a few pixels) then they’re effectively still at the “top” already, but
canScrollBackward
will be true because the scroll state is >0, and so the behaviour might feel a bit strange to the user.. but I’ll leave that one up to you 😄
View count: 25