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

    RE

    06/05/2021, 3:17 PM
    How to add a video player into compose? AndroidView() is not good
    k
    c
    • 3
    • 5
  • s

    Saiedmomen

    06/05/2021, 4:29 PM
    Bottomsheetscafold has a problem where the sheet is detached for a frame if bottom sheet state is expanded. Here is the breakpoint screenshot of
    BottomSheetScaffoldSample
    with initial value of bottomsheetstate set to expanded.
    • 1
    • 3
  • m

    MBegemot

    06/05/2021, 4:43 PM
    Problems related to theming are back ...
    z
    • 2
    • 1
  • m

    MBegemot

    06/05/2021, 6:35 PM
    Well, when you switch between themes programmatically, for some reason those changes produce weird behavior in the app, in particular in the context of Lazylist, it looks like some elements in the list retain the old theme ... If needed I can give you screen shoots . But again changing themes at run time has been an issue for many time
    🧵 1
    a
    d
    • 3
    • 3
  • p

    Patrick Duarte

    06/05/2021, 6:56 PM
    Hi lads, lasses, does anyone know why my Card inside a lazyColumn loses its state after scrolling if I wrap its content with two Rows or Columns? As far as I understand, hoisting is holding values state on its "parent's scope" or where the Composable is being called. Here I attach two screenshots, the first one shows the lazyColumn and the Emulator's example with the double rows., the second one shows the listItem without double Rows. Both emulator examples are after scrolling. I was wrapping a Row inside another one, in order to use the .align modifier. Don't pay attention to the Greeting code since it was to clear some doubts, check if I was losing the state, or the problem was something else.
    b
    c
    a
    • 4
    • 9
  • y

    YASAN

    06/06/2021, 12:41 AM
    On non-compose apps I had to add
    <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
    to my
    styles.xml
    so the notch background would look right, but I cant find the compose version for controlling this.
    c
    • 2
    • 9
  • c

    Colton Idle

    06/06/2021, 3:29 AM
    Does something like epoxys "carousel" exist in the compose community yet? The biggest thing that I want is a horizontal scrolling list of cards that can snap, and have a customized peek value. Super useful for mimicking something like Airbnbs carousels that are seen all throughout their app.
    s
    c
    +2
    • 5
    • 6
  • p

    Pablo Carbajal

    06/06/2021, 6:46 AM
    How do you display an image in compose?
    Image(
        painter = painterResource(id = R.drawable.logo),
        contentDescription = null
    )
    I saw that in the docs, but it does not work. Do assets usually go in /res/drawable ? I saw another google guide saying to make a new folder called "assets"
    z
    p
    • 3
    • 3
  • n

    Namig Tahmazli

    06/06/2021, 8:56 AM
    After switching to compose version beta08, updating kotlin version to 1.5.10 I am stuck on the build error which is in 🧵 I compared my setup with Crane sample app so I could not spot specific differences. I also searched on Google. It seams it is general compiler issue so I did not find something useful related to compose. Stack trace and build file snippets in thread. Any help is appreciated 🙇‍♂️
    ➕ 2
    v
    c
    a
    • 4
    • 6
  • s

    Spikey Sanju

    06/06/2021, 9:10 AM
    [✅ RESOLVED - Solution in thread!] Hello All, after updating to compose version
    beta-08
    &
    Compose nav graph
    dependencies. I’m not able to scope my
    viewmodel
    to the
    nav graph component
    🙇‍♂️🏻 Code sample in thread 👇
    👍 1
    • 1
    • 3
  • z

    Zan Skamljic

    06/06/2021, 9:35 AM
    I'm having some trouble with ripple on FABs, a simple click does not trigger the ripple at all, while a long press does. Is there a way to make the ripple show always, and possibly change the color as well?
    👀 1
    t
    a
    l
    • 4
    • 15
  • s

    ste

    06/06/2021, 9:36 AM
    Hi all...
    start.linkTo(anchor = parent.start, margin = 36.dp)
    leads to the first image (start margin is okay, but I'd like to set a end margin too) But when adding
    end.linkTo(anchor = parent.end, margin = 36.dp)
    , it leads to the second image, where none of the margin is okay because the text is too large. What can I do? Adding a
    padding
    won't work because the lower text (
    0
    ) wouldn't be aligned to the upper text
    c
    • 2
    • 6
  • s

    Spikey Sanju

    06/06/2021, 10:15 AM
    Hello All 👋 , Why
    CombinedClickable
    takes
    1-2 seconds
    to perform action?. Is there any workaround solution for this? Code in Thread 🙇
    s
    c
    +3
    • 6
    • 12
  • z

    Zan Skamljic

    06/06/2021, 11:27 AM
    what is the compose equivalent of StaticLayout? it'd like to draw mutiline text bounded by a certain width
    s
    p
    • 3
    • 10
  • n

    Nana Vong

    06/06/2021, 12:35 PM
    if I do like this, Surface will always recompose .but if I use thread or dispatch another thread Surface will not recompose .Why ?
    Surface {
        darkMode.value = !darkMode.value
    }
    this way not recompose:
    Surface {
        thread {
            darkMode.value = !darkMode.value
        }
    }
    🙅🏼 1
    🤯 4
    🙅 3
    a
    d
    g
    • 4
    • 24
  • n

    nglauber

    06/06/2021, 1:18 PM
    I’m very curious about this question… Should it be a simple thing? https://stackoverflow.com/questions/67852367/how-to-get-the-current-padding-applied-to-a-modifier-in-jetpack-compose
    a
    • 2
    • 6
  • h

    Hachemi Hamadi

    06/06/2021, 2:02 PM
    Hello guys, i have few questions. 1- I couldn't figure out how to get something like this with Compose. I have a text element but couldn't not figure how to make these custom border. Which are shown when the element is clicked and gone when i click outside of it. 2- Is it okay if i have multiple texts elements, photos, and shapes all drawn in the same Box with tap gestures for each one (from performance perspective)
    👍 1
    n
    s
    m
    • 4
    • 9
  • k

    Kulwinder Singh

    06/06/2021, 3:06 PM
    Hi, is there any api available to select Vibrant or any other color from Image loaded using Coil ? or i have to use existing palette api ?
    z
    c
    • 3
    • 6
  • a

    Apm29

    06/07/2021, 3:14 AM
    does CircularProgressIndicator has property like secondaryProgressColor or sth similar?
    z
    n
    • 3
    • 3
  • r

    Ravi

    06/07/2021, 8:31 AM

    https://youtu.be/B1u7JZ1rLyE?t=453▾

    ConstraintLayout allows to use json to describe constraints. I couldn't find any documentation on it. Does anyone have a link to the docs for the json constraints ?
    r
    • 2
    • 6
  • j

    JulianK

    06/07/2021, 1:36 PM
    I really like that Card/Surface now have a onClick property that clips the indication by default (see https://kotlinlang.slack.com/archives/CJLTWPH7S/p1622670428197900). But is it on purpose that there is no possibility to have a Card or Surface without a direct onClick property and that does not block any interaction on it ? The required surface function is private 😞 I cannot apply a clickable modifier on an outer component - once a card is inside, the card will block all clicks on it. Can we get a non-clickblocking Card/Surface please?
    m
    • 2
    • 1
  • r

    RE

    06/07/2021, 3:35 PM
    Does anyone have this problem? https://issuetracker.google.com/issues/190066274 Is this a bug?
    n
    i
    n
    • 4
    • 7
  • r

    robnik

    06/07/2021, 7:43 PM
    The doc example for multiple back stacks & bottom navigation causes the bottom icon to highlight when you are exactly at that destination. Shouldn't it also highlight if your stack is rooted at that destination? In other words, if the bottom nav items are A,B,C,D; and you go from B to E, so your back stack is [B,E], shouldn't the bottom nav show B as selected/highlighted?
    i
    s
    t
    • 4
    • 11
  • l

    Luis Mierez

    06/07/2021, 9:51 PM
    I’m trying to do an infinite list with
    LazyColumn
    without the paging library and I’ve come up with something that works but just want a sanity check since I’m still new to compose. Code in thread
    👀 1
    s
    • 2
    • 5
  • m

    Mayank Saini

    06/08/2021, 5:48 AM
    I am facing this issue where
    placeholder
    and
    leadingIcon
    are not properly aligned.
    placeholder
    is aligned to the top while the
    leadingIcon
    is in centre. I want both of them to be in centre. What is the solution for this?
    t
    • 2
    • 3
  • j

    james

    06/08/2021, 7:08 AM
    In Beta08, I have a composable function that takes a list of items and contains a
    LazyColumn
    . It receives the list of items from a flow in a parent composable via
    collectAsState
    . When the flow emits a new list of values, the composable function containing the
    LazyColumn
    appears to get called with the updated list of items. However, unless the parent of the
    LazyColumn
    composable is recomposed itself (which it it does not appear to be even though the
    collectAsState
    appears to being emitting new values to the child composable) the list UI does not update with the latest list state. This behavior doesn't appear to occur in Beta07. Anyone else encountered this or have any ideas?
    a
    • 2
    • 3
  • a

    Adrian Landborn

    06/08/2021, 7:08 AM
    I am trying to dive in to Accessibility and Compose. A
    Checkbox
    is 24x24dp which is no-no, needs to be at least 48x48dp to pass the checks. So my approach is to combine
    Checkbox
    with
    Text
    to increase the width and add som internal padding to fix the height. Also add the same
    onClick
    on both items. But this does not work. Any advice? As soon as I add any padding, the
    mergeDescendants
    stops working. Is it a bug?
    var checkedState by remember { mutableStateOf(false) }
    Row(
        Modifier
            .clickable { checkedState = !checkedState }
            .semantics(mergeDescendants = true) {}
            .padding(top = 12.dp, bottom = 12.dp)
    ) {
        Checkbox(
            checked = checkedState,
            onCheckedChange = { checkedState = !checkedState })
        Text(text = "Some label", modifier = Modifier.padding(start = 8.dp))
    ➕ 1
    b
    j
    • 3
    • 20
  • m

    Marko Novakovic

    06/08/2021, 8:43 AM
    am trying to add
    AnimatedVectorDrawable
    to am icon but am getting
    android.content.res.Resources$NotFoundException: Resource ID #0x0
    . I have drawable in resources and am passing correct id to the
    animatedVectorResource
    . any help? if that’s relevant in my drawable resource file am using
    animated-selector
    that animates between two `item`s with `transition`s defined in that selector. Update:
    animated-selector
    animating two
    animated-vector
    s. one vector from plus to minus other from minus to plus icon. BUT when I pass just minus to plus
    animated-vector
    to
    animatedVectorResource
    animation works and it knows how to reverse it
    d
    • 2
    • 5
  • r

    RE

    06/08/2021, 9:03 AM
    does the textfield broken? When I click THE outside part of textfield, the IME is not folded
    n
    a
    • 3
    • 13
  • d

    dimsuz

    06/08/2021, 11:53 AM
    Is it a good practice to nest LazyColumns? Why I'm considering this: I have this layout: toolbar + composable + LazyColumn, and the thing is that items in that column need to be inside a bottomsheet-like Surface with white background and elevation (cast a shadow). See screenshot in the thread. And I need a nested scroll to eventually hide toolbar + composable.
    d
    n
    +4
    • 7
    • 25
Powered by Linen
Title
d

dimsuz

06/08/2021, 11:53 AM
Is it a good practice to nest LazyColumns? Why I'm considering this: I have this layout: toolbar + composable + LazyColumn, and the thing is that items in that column need to be inside a bottomsheet-like Surface with white background and elevation (cast a shadow). See screenshot in the thread. And I need a nested scroll to eventually hide toolbar + composable.
Here's a concept screenshot, notice the shadow below bottom-sheet-like surface, currently that's laid out like this:
Column {
  Toolbar()
  HeaderComposable()
  Surface {
    LazyColumn {
      item { SheetHandle() }
      items(bottomSheetItems) { ItemComposable() }
    }
  }
}
d

Dominaezzz

06/08/2021, 12:09 PM
Nesting lazy column is bad practice for sure. Just use a single one and add all the items in it.
☝️ 1
n

nitrog42

06/08/2021, 12:25 PM
why don't you use a BottomSheetScaffold to display the content of your bottom sheet ?
c

Colton Idle

06/08/2021, 12:44 PM
A lazy column essentially has infinite height which is why you can't have a lazy column inside of a lazy column.
d

dimsuz

06/08/2021, 1:36 PM
1. I want to try to use a single one, but there's no way to add that sheet-like thing with elevation. those
Apple Inc
things are individual items. How would you do it? set elevation on each of those little items excluding a toolbar and the composable below? 2. BottomSheetScaffold won't work, because this is not an actual bottomwheet it's part of scrollable content, and everything above it slowly fades as it translates up. Designer vision 🙂
z

Zun

06/08/2021, 1:36 PM
You should also check if you really need a LazyColumn. If all items fit the screen then you can’t recycle anyway.
d

dimsuz

06/08/2021, 1:36 PM
It seems I really need it. There can be thousands of these items on the bottom
n

nitrog42

06/08/2021, 1:42 PM
you can still fight the designer 🥊 I think you can still use the bottomsheetscaffold as you can react to sheet movement (which would allows to translate + fade the content ?) and how I usually handle those situation -> I explain to the designer that I'm tied to the component the system provide me, as designing a screen with custom component is completely possible, but it can multiply times you pass making the screen double, triple or worse
here we can definitelly see a Material BottomSheet so... you can definitelly but a lazycolumn in it and it will scroll as wanted
d

dimsuz

06/08/2021, 1:44 PM
Yeah, I can fight them, but for now I have time to play a bit, so that's what I'm trying 🙂
👍 1
Thanks, will try to take that route too
z

Zach Klippenstein (he/him) [MOD]

06/08/2021, 1:49 PM
You can certainly nest scrollables that scroll on the same axis, and that’s a valid way to implement collapsing toolbars. Compose provides a pretty powerful api for handling nested scroll events. You can also nest lazy scrollables that scroll on different axes, eg
LazyRow
inside
LazyColumn
items. What’s bad is to nest lazy scrollables on the same axis, because only the outer one will actually be lazy. The reason is that the outer one measures its items without bounds on the scroll dimension, which means the inner one will always measure to its full height and never actually “use” laziness.
d

dimsuz

06/08/2021, 2:09 PM
I see, thanks!
a

Albert Chang

06/08/2021, 2:19 PM
Pretty easy to do using
Modifier.nestedScroll()
I think.
d

dimsuz

06/08/2021, 2:24 PM
I tried that but didn't yet figure out how to expand Surface height while LazyColumn inside it scrolls (see layout scheme above)
a

Albert Chang

06/08/2021, 2:38 PM
You don't need to change the height. The surface's height should always be the max height. Basically you set the nested scroll modifier on the surface's parent, and on pre scroll, consume scroll delta and offset the surface.
d

dimsuz

06/08/2021, 2:42 PM
oh. I will try that, thank you
Tried this and the difficulty is how to calculate initial Surface offset. I've put everything in a Box (to let the Surface occupy max height), but initially it must be placed under the toolbar and header.
a

Albert Chang

06/08/2021, 3:10 PM
A simple custom layout should work.
d

dimsuz

06/08/2021, 3:11 PM
Thought about this too, trying to write one 🙂
a

Albert Chang

06/08/2021, 3:47 PM
Wrote a quick sample.
Untitled.kt
n

nitrog42

06/08/2021, 4:11 PM
btw I just looked how to do it when it's not a "first"/"last" item you want, you can use : Modifier.layoutId(layoutId: Any) and then
val iconPlaceable = measurables.first { it.layoutId == "icon" }.measure(constraints)
(found in JetSnack sample)
d

dimsuz

06/08/2021, 4:34 PM
Wrote a quick sample.
Great, thank you! I ended up with something like this, but my version doesn't do flings properly. Yours has the fling not working until the surface is fully expanded, but then it works. I tried to look how bottom sheet scaffold does it's flings and it uses SwipableState + modifier, and all this starts to overwhelm me 🙂 Need to rest.
btw I just looked how to do it when it's not a "first"/"last" item you want
Niice, didn't know about this trick!
a

Albert Chang

06/08/2021, 11:47 PM
Note that for fling to work properly before the surface is fully expanded, you need this bug fix which will likely land in the next beta release.
d

dimsuz

06/09/2021, 9:34 AM
wow, that's great, thanks!
View count: 4