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

    Mohammad Sianaki

    10/09/2021, 1:25 PM
    Hi. I’m trying to implement a collapsing toolbar but my code is so laggy, and it causes recomposition of screen body while scrolling screen.
    @Composable
    fun Demo() {
        val scroll = rememberScrollState(0)
        Column(modifier = Modifier.fillMaxSize()) {
            CollapsingToolbar(scroll = scroll.value, title = "Screen Title")
            Body(scroll)
        }
    }
    
    
    @Composable
    fun Body(scroll: ScrollState) {
        Column(
            modifier = Modifier
                .fillMaxSize()
                .verticalScroll(scroll)
        ) {
            repeat(5) {
                Box(
                    modifier = Modifier
                        .fillMaxWidth()
                        .height(200.dp)
                        .background(Color.Red)
                )
            }
        }
    }
    
    @Composable
    fun CollapsingToolbar(
        scroll: Int,
        title: String,
        onNavigateUpClicked: () -> Unit = {},
    ) {
        val collapseRange = with(LocalDensity.current) {
            (150.dp - 56.dp).toPx()
        }
        val collapseFraction = (scroll / collapseRange).coerceIn(0f, 1f)
        Box(
            modifier = Modifier
                .fillMaxWidth()
                .heightIn(min = 56.dp)
                .wrapContentHeight()
                .background(Color.Green),
        ) {
            IconButton(
                onClick = onNavigateUpClicked,
                modifier = Modifier
                    .padding(start = 8.dp, top = 8.dp)
                    .background(Color.Cyan)
                    .align(Alignment.TopStart)
    
            ) {
                Icon(
                    imageVector = Icons.Default.ArrowBack,
                    contentDescription = null,
                    modifier = Modifier.background(Color.Red)
                )
            }
            Text(
                text = title,
                style = MaterialTheme.typography.h6,
                modifier = Modifier
                    .padding(start = 24.dp, top = 150.dp * (1 - collapseFraction))
                    .align(Alignment.CenterStart)
                    .offset(x = 32.dp * collapseFraction)
            )
        }
    }
    🧵 4
    j
    z
    • 3
    • 3
  • e

    eygraber

    10/10/2021, 1:44 AM
    Did the `getValue`/
    setValue
    import issue ever get resolved? I thought I saw that it was a while ago, but I'm re-exploring Compose and I'm running into issues with it not getting imported.
    z
    • 2
    • 1
  • n

    Nikhil

    10/10/2021, 7:09 AM
    Is there a way to preserve the drawing buffer/frame in canvas? If i’m using
    LaunchedEffect(){…}
    along with
    withFrameNanos{..}
    to update a state (using loop, say for creating a game or animation). Can the previous frame be preserved without recomposition in jetpack compose? Something like
    preserveDrawingBuffer
    in JS.
    z
    • 2
    • 4
  • e

    elye

    10/10/2021, 10:20 AM
    Hi here… I’m trying out hybrid of RecyclerView and ComposeViewHolder.. but looks like everytime it binds, it
    setContent
    , cause to it be slower. The profile looks as the image below. How can it be speed up? FYI, the detail question in. https://stackoverflow.com/questions/69514265/how-to-make-recyclerview-with-composable-viewholder-render-faster
    a
    s
    +2
    • 5
    • 7
  • a

    alorma

    10/10/2021, 3:23 PM
    Alert dialogs with lists looks... weird
    a
    • 2
    • 3
  • c

    Csaba Szugyiczki

    10/10/2021, 4:06 PM
    [ScrollView fillViewport] There were a few discussions about how to replicate ScrollView-s fillViewport=true behaviour. The same can be definitely achieved with a Column having
    fillMaxHeight
    height, and then applying the
    verticalScroll
    modifier on it. But if we use an inner Column, then the way it is measured is different than what we got used to using XML layouts. Setting an inner Columns height to
    wrapContentHeight
    and applying
    .weight(1f)
    on it only respects the weight modifier, but the
    wrapContentHeight
    modifier is ignored. This makes the
    Column
    cut its children. Is there a workaround for this? Sample code in 🧵
    ➕ 2
    a
    • 2
    • 9
  • m

    Matti MK

    10/11/2021, 7:57 AM
    Are there any sample projects available where Kotlin Flow, without LiveData, is used with Compose?
    c
    s
    • 3
    • 3
  • m

    Michael Ndiritu

    10/11/2021, 8:10 AM
    Hello, in compose how can we prevent the app from switching to dark mode when system goes to dark mode
    c
    c
    • 3
    • 2
  • z

    Zoltan Demant

    10/11/2021, 9:14 AM
    Is it possible to specify that a text should use the condensed style, similar to how you might specify its font-weight; or do I need to specify a completely different TextStyle which points to the condensed variant?
    a
    • 2
    • 8
  • z

    Zoltan Demant

    10/11/2021, 10:51 AM
    Is it possible to specify a LazyList to be the size of its largest child? When using a LazyRow with different item heights, the height is always that of the largest currently visible item - scrolling past a large item will jump the entire UI due to the LazyLists height being reduced.
    c
    i
    d
    • 4
    • 5
  • o

    Orhan Tozan

    10/11/2021, 11:12 AM
    I think the Modifier system is really clever designed
    🙏 1
    k
    c
    • 3
    • 2
  • m

    Mike Speed

    10/11/2021, 1:46 PM
    BadgeBox(badgeContent = { Text(value) }) {
             //whatever
         }
    I have a
    BadgeBox
    like this, but if the value is
    0
    , I want to badge to be hidden. If I pass null to
    badgeContent
    , the circle still shows but with nothing in it. How do I hide it completely while still showing the inner content?
    a
    l
    • 3
    • 6
  • b

    bodo

    10/11/2021, 1:59 PM
    Hi. Can you please tell me why padding is not working in this composable:
    Surface(
        modifier = Modifier.padding(10.dp)
        shape = AppTheme.shapes.medium,
        color = AppTheme.colors.surface
      ) {
      content()
    }
    It is only working when i add a box around the content(). is this the correct way to do it???
    Surface(
        shape = AppTheme.shapes.medium,
        color = AppTheme.colors.surface
      ) {
      Box(modifier = Modifier.padding(10.dp)) {
        content()
      }
    }
    d
    • 2
    • 1
  • c

    Cicero

    10/11/2021, 3:49 PM
    Hello, so, I'm curious about architecture. We are now wrapping our UI with something that handles our viewmodel and states and then providing the UI with information rather then passing in the viewmodel. Right? So, starting here how do we handle when there are too many parameters being passed to the UI, like 20? In my mind, when I read trough this case I would leave it as is because it was pretty much explanatory. I also had an option to break it in several smaller UI components but it looked off and ugly (like, let's say, header body and footer) How are you handling your viewmodel and UI when your UI needs to receive too many parameters?
    👀 1
    d
    c
    +4
    • 7
    • 27
  • d

    Damian Zawadzki

    10/11/2021, 5:35 PM
    Guys how would you handle mixing callback based and hosted object based approaches? I got some sample code where I've started with object like here: https://github.com/androidx/androidx/blob/androidx-main/compose/docs/compose-api-guidelines.md#hoisted-state-types But I want to use this composable with callback after all. Sample in thread. I've used launched effect to translate changes of property to callback. Do you have any solutions / patterns to handle case like this?
    • 1
    • 2
  • m

    Mahmoud Alim

    10/11/2021, 8:50 PM
    hello everyone, does anyone came across a proper solution to customize ripple effect with rounded corners as it’s container let’s say a Box with background rounded shape corners ?
    c
    c
    l
    • 4
    • 7
  • a

    aherbel

    10/11/2021, 11:34 PM
    hi everyone… just a question which I didn’t find any answers in the internet… is there a way to do navigation in Compose without the Jetcpack Compose Navigation component? I would like to learn the “native” way to do navigation in Compose before moving to Navigation component… I didn’t find any articles/questions in StackOverflow or anything else that talks about this
    k
    c
    +2
    • 5
    • 12
  • s

    Shabinder Singh

    10/12/2021, 6:35 AM
    Hello Everyone, Few months earlier when Compose was still alpha and a lot of performance improvements were being made, two things were there I wanted to know about and whats their status • Inlining Composable components was also being talked about , what happened to that ? • Multi-threaded Composition ? 🤔
    z
    a
    +2
    • 5
    • 5
  • t

    Tgo1014

    10/12/2021, 7:40 AM
    What’s the proper way to show an one time even? For example a toast from a
    SharedFlow
    ?
    c
    d
    • 3
    • 7
  • f

    Filippo Vigani

    10/12/2021, 9:25 AM
    Hey guys, I was fiddling around with compose layouts(such as
    Row
    ,
    Column
    ,
    LazyVerticalGrid
    and the accompanist
    FlowRow
    ) trying to achieve something like CSS `minmax` function for columns. Basically I'd like to lay out a list of elements such that they take all the available space, as in visually they always occupy the whole width of the screen, but are still constrained by a min size and a max size. Is there any way to achieve that using Jetpack Compose?
    • 1
    • 2
  • k

    K Merle

    10/12/2021, 10:21 AM
    ViewModelScope is canceling a network request when user pops composition where ViewModel is injected. Is it possible to send a network request inside a Side-effects without interruption upon exiting the composition?
    c
    a
    • 3
    • 6
  • u

    Utkarsh Tiwari

    10/12/2021, 2:27 PM
    Is there any way to override the default alpha value of ripple across my app?
    l
    • 2
    • 7
  • t

    Tolriq

    10/12/2021, 3:58 PM
    Any insight about https://issuetracker.google.com/issues/202309451 or a possible workaround?
    👀 3
    t
    • 2
    • 1
  • a

    Ashu

    10/12/2021, 5:17 PM
    I have a few doubts 🙂: • Is there any standard for storing colors/dimens/multi-language string resources in Compose? • Is keeping these resources in XML still the standard practice or is it idiomatic to store these resources in Kotlin files in compose? • If we are storing them in Kotlin files, what could be considered a clean way to support multiple themed colors or multiple language strings? • Also, is there any benefit to keeping all dimens in a single place in compose?
    t
    • 2
    • 1
  • c

    Chris Fillmore

    10/12/2021, 5:37 PM
    Is there some behaviour difference between
    BasicTextField
    and
    TextField
    with respect to cursor placement and/or LTR/RTL behaviour? The code below produces a text field where the cursor stays to the left, and thus text comes out “backwards” as you type. A
    TextField
    with the same parameters works as expected. Thanks!
    BasicTextField(
              value = TextFieldValue(text),
              onValueChange = { onValueChange(it.text) },
              textStyle = TextStyle.Default.copy(
                color = Color.White,
                fontSize = fontSize.em,
                fontWeight = FontWeight.Bold,
              ),
              enabled = /* calculated from some state */,
              modifier = Modifier
                .fillMaxWidth()
                .padding(16.dp),
              keyboardOptions = KeyboardOptions(
                autoCorrect = false,
              ),
            )
    • 1
    • 1
  • c

    Colton Idle

    10/12/2021, 5:53 PM
    How can I make these all the same height? Or maybe a more accurate way to put it. How can I make all items in a row, the height of the largest item in the row, while the row itself wraps the content.
    f
    a
    • 3
    • 7
  • e

    eygraber

    10/12/2021, 10:16 PM
    Is it possible to observe changes to a
    SnapshotStateList
    ?
    z
    t
    • 3
    • 4
  • e

    eygraber

    10/12/2021, 10:22 PM
    Also, what are the practical differences (if any) between using
    SnapshotStateList
    and
    Flow<List<T>>.collectAsState
    ?
    z
    • 2
    • 3
  • p

    pavankumar

    10/13/2021, 2:25 AM
    21-10-12-21-31-56.mp4
    i
    • 2
    • 3
  • n

    Nipun Rajput

    10/13/2021, 7:32 AM
    Has someone worked on profileinstaller, Is this really helpful in jetpack compose? https://developer.android.com/jetpack/androidx/releases/profileinstaller
    w
    • 2
    • 2
Powered by Linen
Title
n

Nipun Rajput

10/13/2021, 7:32 AM
Has someone worked on profileinstaller, Is this really helpful in jetpack compose? https://developer.android.com/jetpack/androidx/releases/profileinstaller
w

Will Shelor

10/15/2021, 9:42 PM
I’ve done a tiny bit of research with it, though I’m not very far along with my research. It improves the first run, but is probably not right for all developers- just those looking to optimize the most out of their initial runs
n

Nipun Rajput

10/18/2021, 5:45 AM
Can you share your findings? It would be great help
View count: 2