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

    dimsuz

    11/12/2021, 11:13 AM
    How do I prevent
    PlotColors
    being recreated on each composable function call here? I can't put this in "remember", because
    MyTheme.colors.someColor
    is a
    Composable
    getter:
    fun MyComposable() {
      val colors = PlotColors(
        positiveColor = MyTheme.colors.indicatorContentGreen,
        negativeColor = MyTheme.colors.indicatorBackgroundRed,
      )
    }
    c
    4 replies · 2 participants
  • j

    John Aoussou

    11/12/2021, 11:38 AM
    Does any one know the proper way to access the LiveData that you get from a room database in compose? I'm sure the DB is not empty, because when I do the following the correct entry is printed:
    val items = viewModel.readAllData.observeAsState()
    val TAG = "check"
    val item1 = items.value?.get(0)?.original
    Log.i(TAG,item1.toString())
    However, if I try to show the text in a Text element like so
    Column{
        Text(text = item1!!)
    }
    it tells me the List is empty ¯\_(ツ)_/¯
    c
    4 replies · 2 participants
  • a

    Ademir Queiroga

    11/12/2021, 11:47 AM
    Hello everyone. Does anyone know/have any content about compose compiler/runtime (not strictly related to jetpack compose UI)? For now I was only able to find a KotlinConf 2019 video from Leland Richardson that explains how it works and a recent article by Jake Wharton showcasing Molecule. Other than that I wasn’t able to find anything not UI related… I’m keen to understand more and explore different usages other than UI
    j
    h
    +1
    12 replies · 4 participants
  • f

    Filippo Vigani

    11/12/2021, 12:48 PM
    Hey, I'm trying to create a PDF viewer composable using the PdfRenderer and Coil for loading the bitmaps into a 
    LazyColumn
    . See thread for code. I kind of got it working, however when the bitmap is first loaded (i.e. it doesn't come from the cache), it won't display in the list until I scroll (i.e. after a redraw). I want to make use of the features of 
    LazyColumn
     and only load the PDF pages when they become visible. Is there any better way to achieve this?
    1 reply · 1 participant
  • m

    Marcin Wisniowski

    11/12/2021, 2:36 PM
    Basic question but I can't find a good answer: how do I apply a
    Modifer
    conditionally? Like
    previousModifier().apply{ if(hasPadding) padding(4.dp) }
    , except that doesn't work. (I know why it doesn't work, but I don't know a nice method that works)
    r
    e
    +2
    7 replies · 5 participants
  • n

    Nacho Ruiz Martin

    11/12/2021, 2:44 PM
    Hey! 👋 I’m migrating a design system that implements a lot of components to Compose. Since this work is hard and long, I started by using some
    AndroidView
    to wrap up the traditional view components. I’m using the
    update
    lambda to make the needed adjustments in the view whenever the state changes. Is there a way to only set the properties that changed for real? If I just set everything that comes as parameter of the composable, they are all reset each time one of them changes. For example, if the text on a TextView changes, the TextAppearance is set again. Thanks! 🙇
    c
    l
    5 replies · 3 participants
  • r

    rsktash

    11/12/2021, 4:44 PM
    Can you expose contentPadding param for TopAppBar function with this option?
    s
    l
    22 replies · 3 participants
  • m

    Marcin Wisniowski

    11/12/2021, 4:46 PM
    I have a
    Row
    with two single line `Text`s. The first one has dynamic text, the second one short static text. How can I make
    TextOverflow.Ellipsis
    work on the first
    Text
    ? I want the second
    Text
    to always show fully, and ellipsize the first one if needed. But it doesn't work - the first text pushes the second one offscreen before it starts to ellipsize.
    👀 1
    t
    d
    +2
    16 replies · 5 participants
  • l

    Lucca Beurmann

    11/12/2021, 4:51 PM
    what's the correct way to show a toast triggered by the viewModel in compose?
    :thread-please: 3
    ✅ 1
    d
    c
    +2
    14 replies · 5 participants
  • v

    voben

    11/12/2021, 8:39 PM
    How do I create something like this in compose where there is overlap between the Card and Image? Should I be using Box? I’ve tried a Column with a negative spacing arrangment but that didnt seem to work for me
    d
    c
    +1
    3 replies · 4 participants
  • l

    Lucca Beurmann

    11/12/2021, 8:42 PM
    inside a box scope you have access to the zIndex modifier, which you can use to put elements on top of each other
    v
    1 reply · 2 participants
  • u

    _shtomar

    11/12/2021, 11:29 PM
    Is there any callback or listener to get an event when Composable rendered it’s content for first time or it’s content is changed?
    n
    a
    +1
    5 replies · 4 participants
  • p

    pavankumar

    11/13/2021, 5:22 AM
    Is there anyway to show/hide system bars on list scroll in compose. I tried below approach but no success. Any clues?
    LaunchedEffect(Unit) {
                launch {
                    while (true) {
                        delay(2000)
                        if (!lazyListState.isScrollInProgress) {
                            systemUiController.isNavigationBarVisible = false
                        }
                    }
                }
            }
    c
    1 reply · 2 participants
  • s

    Slackbot

    11/13/2021, 5:40 AM
    This message was deleted.
    t
    1 reply · 2 participants
  • p

    Philip Blandford

    11/13/2021, 12:00 PM
    I want to dismiss a popup with an outside click, but the click doesn’t seem to be consumed by the dismiss action, and is responded to by whatever background item is clicked on. How can I have it so the click just dismisses the popup and nothing else? In the following toy code, my ideal would be for the counter to increment when the popup is not displayed, but not when clicking to dismiss it
    @Composable
    fun PopupTest() {
      val show = remember{ mutableStateOf(false)}
      val ctr = remember{ mutableStateOf(0)}
    
      Box(
        Modifier
          .fillMaxSize()
          .clickable { ctr.value += 1 }) {
        Button({show.value = !show.value}, Modifier.align(Alignment.TopCenter).offset(y = 20.dp)) {
          Text("Show Popup")
        }
        if (show.value) {
          Popup(alignment = Alignment.Center,
            onDismissRequest = {show.value = false}){
            Text("I am the popup", Modifier.border(1.dp, Color.Black))
          }
        }
        Text("Ctr ${ctr.value}",
          Modifier
            .align(Alignment.BottomCenter)
            .offset(y = -20.dp))
      }
    }
    o
    l
    2 replies · 3 participants
  • p

    Paul Woitaschek

    11/13/2021, 5:53 PM
    Does someone know if there is ongoing work to support compose in multiplatform iOS / watchos targets? I mean the compose compiler, not compose ui
    p
    l
    +2
    4 replies · 5 participants
  • m

    Mohamed Ahmed ALi

    11/14/2021, 6:49 PM
    I have an image inside a button. When I'm trying to change the background color of the button by colors = ButtonDefaults.buttonColors(color) the background invoked and hide the image too
    c
    1 reply · 2 participants
  • p

    Paul

    11/14/2021, 9:43 PM
    Hey all. I have a use case, where I need to hide a Text composable based on whether Coil has successfully downloaded the image from a URL or not. However, the current solution I came up with seems to cause infinite recompositions. Thread 👇
    a
    8 replies · 2 participants
  • m

    Mike Speed

    11/15/2021, 11:07 AM
    Hello! I’m using
    accompanist.pager.HorizontalPager
    and for some reason my textviews are always square when the string is longer than one line… any ideas why?
    HorizontalPager(
        count = 2,
        state = pagerState,
        verticalAlignment = <http://Alignment.Top|Alignment.Top>
    ) { i ->
        when (i) {
            0 -> Text(
                    "A string A string A string A string A string A string A string", 
                    modifier = Modifier.wrapContentHeight(), //makes no difference
                )
            1 -> SomethingElse()
        }
    }
    I also tried wrapping in a Row with wrapContentHeight but it didn’t make a difference.
    1 reply · 1 participant
  • m

    Matti MK

    11/15/2021, 11:12 AM
    I need to download an image with Coil on Compose, then draw on the bitmap and finally share the image via Intent. Wondering if anyone has done that in the compose world: how’d you go about it? I was thinking of downloading the image with Coil, accessing the bitmap, drawing it on a Canvas, editing it, saving the bitmap from the canvas into external storage and finally sharing it from there.
    m
    c
    9 replies · 3 participants
  • a

    AmrJyniat

    11/15/2021, 1:43 PM
    How to check from keyboard state whether showing or hiding?
    c
    6 replies · 2 participants
  • n

    Niko

    11/15/2021, 1:55 PM
    I'm wondering if there's something I'm doing wrong, of if the API/Android Studio just doesn't support `Flow`s with the
    @Preview
    composables ATM
    a
    3 replies · 2 participants
  • b

    Bradleycorn

    11/15/2021, 5:20 PM
    I’m using
    LaunchedEffect
    along with
    LocalLifecycleOwner
    in a “Screen” composable to start a long-running/intensive coroutine in my ViewModel only when the containing Activity/Fragment is
    RESUMED
    . More info and code in the 🧵 I’m curious if this is a proper/best solution for my use case or if there are better ways to do this?
    t
    t
    +1
    8 replies · 4 participants
  • m

    mcpiroman

    11/15/2021, 5:37 PM
    Just to be sure - is the the standalone core (non UI) Compose component also licensed to allow commercial use?
    r
    1 reply · 2 participants
  • h

    Hachemi Hamadi

    11/15/2021, 8:25 PM
    Hello, when building release app with
    minifyEnabled true
    the app crashes on startup. I couldn't figure out what's causing it.
    r
    o
    3 replies · 3 participants
  • t

    thelumiereguy

    11/15/2021, 8:55 PM
    Is there a way I can read tombstones in newer Android versions? I'm working on a compose app with WallpaperService. When coming back from the System's Wallpaper Chooser to my app, it's throwing a native crash.
    1 reply · 1 participant
  • c

    Colton Idle

    11/15/2021, 9:20 PM
    I was expecting to see a touch ripple onclick. Is my assumption wrong or am I doing something wrong? Note: My log fires, so the click definitely triggers.
    Box(
        modifier = Modifier
            .border(1.dp, Color.Red)
            .fillMaxWidth()
            .height(72.dp)
            .clickable { Log.e("LOG", "CLICK") }
    ) { Text(text = "MY TEXT") }
    a
    c
    +3
    10 replies · 6 participants
  • c

    Clament John

    11/16/2021, 5:09 AM
    On using BottomNavBar and NavGraph When using Bottom Nav Bar we have to use a Scaffold and pass a NavHost to the content parameter for it to work. But for apps with multiple screen with and without the bottomNavBar (consider instagram home screen and it's user profile screen) - how do we manage navigation? Why isn't there a better approach here? Currently the options we have are (if we wish to use BottomNavBar + other screens without the NavBar) 1. A single Scaffold and a single ViewModel that keeps track of the current screen and conditionally sets the TopBar, BottomNavBar, and content a. Bad because the VM is too large and bloated b. example -

    gif▾

    and the accompanying article 2. Start a new activity when you wish to move from the BottomNavBar activity Questions 1. How to use NavGraphs and BottomNavbar? a. Consider this example i. splash screen ii. login iii. home screen with bottom nav iv. profile screen v. create new video screen
    i
    k
    6 replies · 3 participants
  • n

    Nurseyit Tursunkulov

    11/16/2021, 7:01 AM
    how to make xyz coordinate system in compose? like this:
    d
    1 reply · 2 participants
  • p

    Paul Woitaschek

    11/16/2021, 7:56 AM
    Can an android compose project use a library compiled with kotlin 1.6?
    e
    c
    7 replies · 3 participants
Powered by Linen
Title
p

Paul Woitaschek

11/16/2021, 7:56 AM
Can an android compose project use a library compiled with kotlin 1.6?
e

Ejimax

11/16/2021, 8:56 AM
In my environment (compose 1.0.5) build fails with:
A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
p

Paul Woitaschek

11/16/2021, 8:57 AM
But are you just using kotlin 1.6 or are you using a library compiled with kotlin 1.6?
e

Ejimax

11/16/2021, 8:58 AM
just using kotlin 1.6.
p

Paul Woitaschek

11/16/2021, 8:59 AM
Yep, that never works
e

Ejimax

11/16/2021, 9:00 AM
Is it because other dependencies doesn’t support kotlin 1.6?
c

Csaba Kozák

11/16/2021, 9:38 AM
Compose 1.0.5 only works with Kotlin 1.5.31
p

Paul Woitaschek

11/16/2021, 9:39 AM
I tried it and it works
View count: 4