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

    spierce7

    11/11/2020, 11:17 PM
    What is the proper way to get the height of the screen in Compose for something like this Linear Gradient? I have to specify the height, but what I really want is from the top of the view to the end of the view, which can change depending on the running device. What’s the right way to do this in compose?
    Column(
                Modifier
                    .weight(1f)
                    .fillMaxSize()
                    .background(
                        VerticalGradient(
                            colors = listOf(
                                Color(125, 206, 250),
                                Color(82, 88, 245),
                            ),
                            startY = 0f,
                            endY = 100f
                        )
                    )
            ) {
                SecondarySection()
            }
    l
    v
    • 3
    • 10
  • n

    nitrog42

    11/11/2020, 11:51 PM
    Question, what is your average preview update time ? (like changing a string in the preview how much time does it take to update)
    r
    b
    • 3
    • 4
  • b

    Bradleycorn

    11/12/2020, 12:09 AM
    Anyone using the
    CoilImage
    composable from the Accompanist library that @cb put together? I’m wondering what’s the best way to use a placeholder image resource when my composable is displayed via a
    @Preview
    ? During preview the image state is
    Empty
    , so I thought about using the content composable and setting a placeholder image when image state is empty. That works. But, the placeholder image is also displayed briefly (before the actual image is loaded) when the app is run on a device, and I don’t want that.
    👍 1
    t
    r
    c
    • 4
    • 18
  • r

    redrield

    11/12/2020, 12:46 AM
    What would i have to do to emulate the Active button look in compose?
    a
    c
    • 3
    • 7
  • d

    Denis Sakhapov

    11/12/2020, 3:22 AM
    androidx.compose.runtime.stateFor
    has been removed in
    alpha07
    . What is the replacement for that?
    l
    • 2
    • 3
  • s

    Sam

    11/12/2020, 5:33 AM
    Is there any way to utilize 
    WindowInsetsAnimation
    within a Jetpack Compose project? This allows fine grain control and coordination of the keyboard animation (as described in this article). Most examples I've seen utilize
    setWindowInsetsAnimationCallback
    (like in this sample code) but I'm not sure how this would work in Compose?
    👀 1
    s
    r
    • 3
    • 3
  • d

    Daniel

    11/12/2020, 8:41 AM
    e: java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl org.jetbrains.kotlin.parcelize.ParcelizeResolveExtension$Companion$createMethod$functionDescriptor$1.initialize(org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor, org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor, java.util.List, java.util.List, org.jetbrains.kotlin.types.KotlinType, org.jetbrains.kotlin.descriptors.Modality, org.jetbrains.kotlin.descriptors.DescriptorVisibility)'
    • 1
    • 1
  • r

    Rafs

    11/12/2020, 9:38 AM
    Is there anyway of saving a composable to a
    Bitmap
    Just like what we do with
    View.drawToBitmap()
    p
    n
    f
    • 4
    • 19
  • d

    Dieter Holz

    11/12/2020, 9:58 AM
    Since alpha07 MediaPlayer doesn’t play sounds anymore This worked before (in alpha06)
    private val soundPlayer by lazy { MediaPlayer.create(context, R.raw.transporter) }
    soundPlayer.start()
    R.raw.transporter is a mp3-File Any hints?
    a
    h
    • 3
    • 3
  • v

    Vivek Sharma

    11/12/2020, 11:44 AM
    Hey devs, I was trying compose navigation, and I added the
    implementation "androidx.navigation:navigation-compose:1.0.0-alpha01"
    and I didnt write any code in main activity except the code which is generated at build of new project and app didnt run Logcat showing :
    java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/foundation/Background;
    at androidx.compose.foundation.BackgroundKt.background-1xq40Q0(Background.kt:44)
    at androidx.compose.material.SurfaceKt.Surface-biUpMIw(Surface.kt:101)
    s
    • 2
    • 7
  • g

    Grigorii Yurkov

    11/12/2020, 12:48 PM
    I am wondering, why
    Color
    has 3 properties named
    red
    green
    blue
    if
    Color
    can store non-RGB colors, for instance HSV. Isn't it confusing?
    c
    • 2
    • 10
  • d

    Daniele B

    11/12/2020, 1:54 PM
    After updating to alpha07, the text color on both topbar and bottombar became black (it was white). Is this a bug? I don’t think I have changed anything in my code.
    j
    j
    • 3
    • 4
  • g

    Gifgroen

    11/12/2020, 3:17 PM
    Hey, if I were to have updated compose and get an error, what would be the best way to find out what changed? Aka where do I find the best changelog I can search for this? I get error ->
    unresolv3d reference: InspectableParameter
    c
    • 2
    • 3
  • b

    Bryan Herbst

    11/12/2020, 5:10 PM
    Question/feedback on supporting non-Material design systems and future compatibility: Why are all of the components in
    androidx.compose.material
    named as though they are the the canonical implementation, when the messaging so far is that Material is an implementation of a specific design system?
    Text
    is a great example- it’s name alone ensures that it will be the first text Composable that most engineers reach for, but that presents two problems in my mind: • Today, any project with its own design system has the burden of ensuring its engineers use their design system’s text instead of the innocent and generic sounding
    Text
    • When a new Android-default design system inevitably comes along in the future, we have a similar problem- does the new design system create a
    HoloText
    , create its own Composable named
    Text
    , or does Material rename
    Text
    to something else? Contrast that with the Material Components library with
    View
    s, which explicitly labels the material-themed components e.g.
    MaterialRadioButton
    . There are some tricks under the hood to swap them in for framework components in some cases, but they still get a clear name in the library.
    👍 1
    👀 1
    i
    m
    +5
    • 8
    • 21
  • d

    David Attias

    11/12/2020, 5:31 PM
    Hey guys, I have an issue that occurs randomly: the soft keyboard is not showing up when focusing a TextField. When this happens, I need to relaunch the app and it works the next launch most of the time. I get the following line in the logs.
    D/InputMethodManager: showSoftInput - cancel : mServedView != view : DecorView@c9ce8f2[MainActivity]  view : androidx.compose.ui.platform.AndroidComposeView{800f9 VFED..... ........ 0,0-1080,2181}
    a
    a
    +2
    • 5
    • 10
  • g

    grandstaish

    11/12/2020, 5:38 PM
    Is the concept of ‘assistive helper text’ coming to the material
    TextField
    composable? https://material.io/components/text-fields#anatomy. I realise we can just add text manually underneath the
    TextField
    component, but if it were built-in then you’d get the right text style, color, and positioning for free.
    ✅ 1
    a
    • 2
    • 2
  • z

    Zach Klippenstein (he/him) [MOD]

    11/12/2020, 6:29 PM
    @Leland Richardson [G] Does the new stability inference feature mean that the Stable/Immutable annotations can eventually be deprecated? Are there still cases that the inference misses that need to be explicitly annotated?
    l
    l
    • 3
    • 9
  • s

    Slackbot

    11/12/2020, 7:33 PM
    This message was deleted.
    z
    s
    j
    • 4
    • 4
  • k

    Kirill Grouchnikov

    11/12/2020, 9:58 PM
    I have a case where I want to "tag" a certain subtree as a "logical" grouping of content. For example, in Office you have the ribbon "group", the footer "group", the taskpane "group". One option is to use an ambient to wrap that group, but it feels too heavyweight. And the other option is to use a modifier, but it looks like a modifier only gets "applied" to the specific composable. If I have another composable down the tree and I want to check which logical group it belongs to, there doesn't seem to be a way (by design?) to walk the modifiers of my parent chain. Should I go with ambients?
    z
    a
    j
    • 4
    • 40
  • s

    Sam

    11/12/2020, 11:01 PM
    why doesn't this compile:
    val countries by remember { listOf(Locale.getISOCountries().map { Locale("", it) }) }
    with exception:
    Type 'TypeVariable(T)' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
    i
    z
    • 3
    • 12
  • i

    Ian Sikes

    11/12/2020, 11:09 PM
    hey y'all 👋 I have a question about managing state in Jetpack Compose. Is there a way to perform some "cleanup" on a `remember`'d value before it is recomputed? I'm coming from React land where this is sort of thing is handled by
    useEffect
    . For example:
    val (session, setSession) = remember(sessionId) {
        mutableStateOf(Session(sessionId))
    }
    When the
    sessionId
    changes, a new
    Session
    is created. But I need to call
    session.close()
    beforehand. I can probably think of some hacky way to handle this but I'm trying to figure out what the "correct" Compose way is
    d
    • 2
    • 2
  • a

    Arkadii Ivanov

    11/13/2020, 12:01 AM
    Which approach is more idiomatic in Compose? 1 or 2?
    @Composable
    fun foo1(dependency: () -> Dependency) {
        val x = remember { Bar(dependency()) }
    }
    
    @Composable
    fun foo2(dependency: Dependency) {
        val x = remember { Bar(dependency) }
    }
    j
    a
    • 3
    • 10
  • z

    zoha131

    11/13/2020, 12:26 AM
    after upgrading to latest alpha-07 version I am unable to use CoilImage and getting this fatal error:
    i
    n
    • 3
    • 4
  • f

    fkrauthan

    11/13/2020, 1:04 AM
    Does anyone have any must read articles/tutorials if I want to get started with android compose to build a brand new app?
    v
    a
    • 3
    • 2
  • m

    Mehdi Haghgoo

    11/13/2020, 4:55 AM
    I cannot seem to understand these two lines in the state code lab. private var _todoItems = MutableLiveData(listOf<TodoItem>()) val todoItems: LiveData<List<TodoItem>> = _todoItems If todoItems is immutable val, then how is it constantly updated with _todoItems livedata?
    r
    g
    i
    • 4
    • 4
  • k

    Kshitij Patil

    11/13/2020, 5:25 AM
    I've a "Android Library" module for my common Composables. This module doesn't have any activity as I'm not defining any actual Screen here. How can I test the Composables in this module?
    z
    • 2
    • 1
  • b

    bharat to

    11/13/2020, 7:43 AM
    How to turnoff ripple effect that comes with
    Modifier.clickable()
    ? for every
    *Button
    this behavior is common. I couldn't find any online resources to do this in compose.
    j
    m
    • 3
    • 5
  • a

    Ashwani Singh

    11/13/2020, 9:14 AM
    Hi All, How to convert below code into compose:
    private fun subscribeObservers() {
        homePageViewModel.viewState.observe(this) { viewState ->
            if (viewState != null) {
                viewState.pageUILayoutList?.let { pageUILayoutList ->
                    printLogD("HomePageFragment | pageUILayoutList", pageUILayoutList.toString())
                }
    
                viewState.allModulesForPage?.let { allModulesContent ->
                    printLogD("HomePageFragment | allContents", "" + allModulesContent.toString())
    
                }
            }
        }
    }
    I used below code, but its not work
    val homePageViewModel = (ContextAmbient.current as DashboardActivity).homePageViewModel
    onActive {
        homePageViewModel.setStateEvent(
            HomePageStateEvent.GetPageModuleEvent()
        )
        homePageViewModel.setStateEvent(
            HomePageStateEvent.GetContentEvent()
        )
    }
    val viewState: HomePageViewState by homePageViewModel.viewState.observeAsState(
        HomePageViewState()
    )
    var pageUIMap: HashMap<String, String>? = null
    if (viewState.pageUILayoutList != null) {
      // But not getting any call here
    }
    :thread-please: 1
    z
    • 2
    • 4
  • v

    Vivek Sharma

    11/13/2020, 10:30 AM
    I was using compose-navigation with bottom nav, I got a doubt (As docs stated one is
    Profile Composable
    and other is
    FriendList Composable
    , using as eg. and below as onClick code
    onClick = {
                  // This is the equivalent to popUpTo the start destination
                     navController.popBackStack(navController.graph.startDestination, false)
                     if (currentRoute != screen.route) {
                                navController.navigate(screen.route)
                     }
              }
    ) Lets say So startDestination is
    Profile
    , then we clicked on
    FriendList
    bottom nav item, and then we clicked Profile, then FriendList When I press back, I never go back to FriendList, though I have visited it twice How does popBackStack works here, popping till Profile and not including Profile
    c
    • 2
    • 6
  • a

    Animesh Sahu

    11/13/2020, 11:04 AM
    Hi, how memory (state) management work with compose? How to dispose a object if it does not need to be alive (like View.GONE) 👀
    a
    • 2
    • 2
Powered by Linen
Title
a

Animesh Sahu

11/13/2020, 11:04 AM
Hi, how memory (state) management work with compose? How to dispose a object if it does not need to be alive (like View.GONE) 👀
a

allan.conda

11/13/2020, 11:05 AM
if (state.showComponent) {
  Component()
}
➕ 2
a

Animesh Sahu

11/13/2020, 11:06 AM
O! Thanks :)
View count: 4