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

    Cyril Find

    11/13/2020, 11:18 AM
    Hi 🙂 With compose navigation bottom bar, how can I get the usual behaviour of scrolling to top when tapping the icon of the screen i'm already on ?
    p
    • 2
    • 2
  • k

    Kshitij Patil

    11/13/2020, 11:27 AM
    How to use
    Divider
    as vertical line?
    p
    p
    • 3
    • 3
  • a

    Animesh Sahu

    11/13/2020, 11:33 AM
    From the Thinking in Compose video

    https://www.youtube.com/watch?v=SMOhl9RK0BA?t=10m41s▾

    How would you manage all the click events with single
    content: @Composable () -> Unit
    lambda? How would somebody handle the click events inside the lambda?
    z
    • 2
    • 2
  • s

    salomonbrys

    11/13/2020, 12:42 PM
    Is there a way to detect preview mode?
    p
    j
    s
    • 4
    • 6
  • p

    Pavel Marchenko

    11/13/2020, 1:45 PM
    Hi all, is there a way to apply different 'lineHeight' to a specific region of the text inside [Text] composable?
    z
    • 2
    • 3
  • z

    zoha131

    11/13/2020, 3:47 PM
    Can I create
    viewModel
    scoped to a
    composable
    using
    navigation-compose
    ?
    i
    n
    • 3
    • 9
  • k

    Kirill Grouchnikov

    11/13/2020, 5:20 PM
    https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/compose/ui/ui-graphics/src/commonMain/kotlin/androidx/compose/ui/graphics/Brush.kt#279 is marked as internal, which means that to create a multistop linear gradient (not just an array of colors, but also an array of stops) requires to use the
    ShaderBrush
    +
    LinearGradientShader
    . Is that intentional?
    a
    p
    n
    • 4
    • 5
  • z

    zoha131

    11/13/2020, 7:25 PM
    If I create viewModel inside a composable then I can’t preview the composable. Also, it is recommended to create a composable which is independent of the Navigation Library. And to test UI easily it is recommended to create stateless composable. To solve all of these I am thinking about the following pattern: 1. Every screen composable will have three parameters. (a) state: a data class. (b) viewModelCallback: an interface so that the screen can interact with the viewModel. (c) screenCallback: an interface to interact with navigation and activity results 2. There would be an overloaded version of the screen which will be stateful and will know about navController and viewModel. 3. I will use a stateless screen composable to preview and test. What do you think about this approach? for every screen, I have to create a data class, two interfaces, two dummy implementation of those for preview, and test implementation for those. will these extra works be beneficial or I am over-engineering
    j
    i
    +3
    • 6
    • 28
  • f

    fkrauthan

    11/13/2020, 8:35 PM
    Ok I have two more questions. 1. Since no one was able to point me to the right direction so far: are there any samples of providing different layouts depending if a user is having a big screen or a small screen (e.g. tablet I want side by side and on phone I want two panels below each other) 2. Is there any documentation for all the Material (and non material components)? For some reason I can't find the KotlinDoc for that?
    z
    • 2
    • 2
  • s

    Sam

    11/13/2020, 8:56 PM
    hi all, i'm trying to interop with an android view inside of compose, specifically this library Konfetti. It's not filling the screen, nor is the animation playing - this is what i have so far:
    @Composable
    fun Confetti() {
        val context = ContextAmbient.current
        val konfettiView = remember {
            KonfettiView(context).apply {
                build()
                    .addColors(Color.YELLOW, Color.GREEN, Color.MAGENTA)
                    .setDirection(0.0, 359.0)
                    .setSpeed(1f, 5f)
                    .setFadeOutEnabled(true)
                    .setTimeToLive(2000L)
                    .addShapes(Square, Circle)
                    .addSizes(Size(12))
                    .setPosition(-50f, 500 + 50f, -50f, -50f)
                    .streamFor(300, 5000L)
            }
        }
        
        AndroidView({ konfettiView }, modifier = Modifier.fillMaxSize()) { view ->
            // Do something here?
        }
    }
    really hard to understand what's going wrong here! any advice?
    z
    z
    +2
    • 5
    • 15
  • d

    David Attias

    11/13/2020, 9:42 PM
    Since Compose Navigation added NavOptions in alpha02, I'm trying to use it but I dont understand how can I specify a popUpTo destination as it requires an Id(Int) and we only have route(string) in the Compose navigation graph. Thanks for your help guys!
    i
    c
    • 3
    • 6
  • y

    Yann Badoual

    11/13/2020, 9:52 PM
    Did something change in alpha07 for ViewModel and hilt usage? In an
    AndroidEntrypoint
    annotated activity, I'm now getting
    has no zero argument constructor
    when using the
    viewModel()
    composable to retrieve an instance (the ViewModel's constructor does have the
    ViewModelInject
    annotation)
    i
    • 2
    • 5
  • r

    redrield

    11/14/2020, 1:54 AM
    How can I get the current orientation of the device in a composable?
    i
    a
    • 3
    • 3
  • r

    redrield

    11/14/2020, 3:07 AM
    E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.redrield.androidds, PID: 15301
        java.lang.NoSuchFieldError: No field Companion of type Landroidx/compose/runtime/SlotTable$Companion; in class Landroidx/compose/runtime/SlotTable; or its superclasses (declaration of 'androidx.compose.runtime.SlotTable' appears in /data/app/~~58hYPPzhGRjb56GwSeeO0g==/com.redrield.androidds-WjdLhG2Oom4gM1SnqQGjqg==/base.apk)
            at androidx.compose.material.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:112)
    Any idea why this would be happening? It started after I added compose-navigation, even if I've cut out all reference to it where the theme composable is being called, in fact there's no content there at all
    b
    • 2
    • 6
  • r

    redrield

    11/14/2020, 3:08 AM
    implementation 'androidx.compose.ui:ui:1.0.0-alpha07'
        // Tooling support (Previews, etc.)
        implementation 'androidx.ui:ui-tooling:1.0.0-alpha06'
        // Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
        implementation 'androidx.compose.foundation:foundation:1.0.0-alpha06'
        // Material Design
        implementation 'androidx.compose.material:material:1.0.0-alpha06'
        // Material design icons
        implementation 'androidx.compose.material:material-icons-core:1.0.0-alpha06'
        implementation 'androidx.compose.material:material-icons-extended:1.0.0-alpha06'
        // Integration with observables
        implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-alpha06'
        implementation "androidx.navigation:navigation-compose:1.0.0-alpha02"
    compiler extension version 1.0.0-alpha06
    i
    b
    • 3
    • 6
  • k

    Kshitij Patil

    11/14/2020, 5:15 AM
    In Jetchat, when the Selector is Expanded, if I put app in the background and reopen it, keyboard is also shown. Is this expected behaviour?
    j
    p
    • 3
    • 2
  • s

    Se7eN

    11/14/2020, 2:16 PM
    Anyone made a color wheel with compose? I'd love to check it out
    v
    • 2
    • 3
  • e

    Eric Ampire [MOD]

    11/14/2020, 2:19 PM
    Hello, what is the equivalent of fitSystemWindows in Jetpack Compose ?
    n
    • 2
    • 2
  • s

    Se7eN

    11/14/2020, 3:36 PM
    How can I make a sweep gradient?
    n
    • 2
    • 3
  • m

    Mihai Hrincescu

    11/14/2020, 7:19 PM
    Hello, does anyone know why the compose canvas does not have a function to draw text similar to the native canvas? Is it not implemented yet or we should just use the
    drawContext.canvas.nativeCanvas()
    ?
    s
    • 2
    • 10
  • g

    Gabriel

    11/14/2020, 7:46 PM
    Hey, what's the best way to set the children of a row to a certain width based on percentage rather than a concrete value? Or is it best to calculate the concrete value?
    • 1
    • 2
  • y

    Yann Badoual

    11/14/2020, 8:02 PM
    Are returns inside composable currently bugged (alpha07)? I'm getting a lot of
    java.lang.IllegalStateException: Start/end imbalance
    when using them Wrapping the whole follow code into a conditional block instead fixes the issue
    r
    l
    +2
    • 5
    • 22
  • z

    zoha131

    11/14/2020, 10:20 PM
    Have anyone tried nested navigation? When I make the nested navigation the startDestination then it works otherwise I can’t go to the nested navigation. How can I navigate to the nested navigation?
    ShohayTheme {
                    val navController = rememberNavController()
    
                    NavHost(navController = navController, startDestination = Route.Splash) {
                        composable(Route.Splash) {
                            val splashViewModel = hiltViewModel<SplashViewModel>()
                            SplashScreen(
                                viewModel = splashViewModel,
                                navigateToAuth = { navController.navigate(Route.Auth) },
                                navigateToHome = { navController.navigate(Route.Main) }
                            )
                        }
    
                        navigation(startDestination = Route.NestedAuth.Social, route = Route.Auth){
                            composable(Route.NestedAuth.Social) {
                                Text(text = "Social Flow")
                            }
                        }
    
                        composable(Route.Main) {
                            Text(text = "Main Flow")
                        }
                    }
    
                }
    :thread-please: 1
    i
    • 2
    • 6
  • t

    Tlaster

    11/15/2020, 3:54 AM
    Seems like using paging compose
    items
    with
    LazyColumn
    does not restore the scroll position when navigate back using navigation compose. Does anyone have the same issue?
    a
    j
    m
    • 4
    • 7
  • t

    Tash

    11/15/2020, 5:12 AM
    After updating to
    alpha07
    & chrisbanes/accompanist v0.3.3.1 , loading a
    CoilImage
    in this manner:
    CoilImage(
        contentScale = ContentScale.Crop,
        data = "some image url",
        fadeIn = true,
        error = { Text("Could not load image") }
    )
    fails with:
    skia: --- Failed to create image decoder with message 'unimplemented'
    The result is that the image does not load, and the error Composable is shown. Anyone else experiencing this?
    s
    • 2
    • 1
  • m

    Mahdi

    11/15/2020, 8:49 AM
    Hi. I have a LiveData<List<Items> that Observe it inside composable like:
    val items = viewModel.liveDataItems.observeAsState(initial = emptyList())
    After user do some action I wanna expand that specific item. For do that I will tell viewModel update expandation field of selected item. Then I will update liveDataItems and want to expandations happens. I have two problem here, first making change to list items not trigger Live Data in compose so I have to replace all data with new that specific items is updated with isExpanded=true. Second issue is with tis way I will lose my scroll point and view will render from start. How I can handle expandation like this to have
    p
    • 2
    • 2
  • v

    Vivek Sharma

    11/15/2020, 11:24 AM
    What can be this composable, it has fixed height, not expandable (adding task in Google Tasks App)? I have used BottomDrawerLayout , but it doesnt let fix height , any idea? 🤔 Is it something similar to Crane app?
    s
    • 2
    • 23
  • p

    Pavel Marchenko

    11/15/2020, 1:22 PM
    Hi all, I'm using
    EditText
    view with
    AndroidView
    composable, when I press back button with
    EditText
    in active state,
    KeyInputModifier
    is crashing with
    "KeyEvent can't be processed because this key input node is not active."
    Is there any information on what i'm doing wrong and how to fix this? After a briefly looking into compose source code I was not able to find any handle to prevent this crash, so I'm just suppressing the crash on activity level inside of
    dispatchKeyEvent
    method, is there a better workaround for the issue? (compose 1.0.0-alpha07)
    d
    • 2
    • 3
  • a

    Ali Albaali

    11/15/2020, 1:37 PM
    Is there a way to parse a string to Color in Compose? 🤔
    p
    k
    • 3
    • 2
  • g

    grandstaish

    11/15/2020, 2:07 PM
    Why is nesting `ScrollableColumn`s not allowed? My use case: I’m making my own
    TextField
    component, and it internally needs a
    ScrollableColumn
    so that users can scroll when the text height is greater than the container size. Having an internal
    ScrollableColumn
    prevents me from putting this
    TextField
    in a screen with scrollable content (i.e. most screens)
    m
    • 2
    • 4
Powered by Linen
Title
g

grandstaish

11/15/2020, 2:07 PM
Why is nesting `ScrollableColumn`s not allowed? My use case: I’m making my own
TextField
component, and it internally needs a
ScrollableColumn
so that users can scroll when the text height is greater than the container size. Having an internal
ScrollableColumn
prevents me from putting this
TextField
in a screen with scrollable content (i.e. most screens)
Looking at the source code for Material
TextField
, they just built their own
ScrollableColumn
that doesn’t crash in this scenario?? 😄 Makes me feel like either Material is doing something bad, or
ScrollableColumn
is being too restrictive.
m

matvei

11/16/2020, 11:37 AM
Nesting of
ScrollableColumn
is allowed and supported as far as I'm aware. The problem you see arising because ScrollableColumn measures its children with infinite constraints, so you have to limit your child
ScrollableColumn
to some height it order for it to work. Having said that, putting
ScrollableColumn
in
TextField
to scroll might solve your issue short term, but it's more complicated than that. You need to be able to scroll when cursor is dragged, you need to be able to auto-scroll down or up when line is added/removed, that's why we embed scrolling logic inside TextField. Since it's not a trivial task, in the upcoming releases we will port this logic to the
BasicTextField
as well, so any TextField you use will have this logic build-in, not only material 🙂 Let me know if you have any questions
g

grandstaish

11/16/2020, 12:11 PM
Ah ok, this explains a lot, thank you for the in-depth reply! This is also fantastic news: porting it over to
BasicTextField
solves my main concern of having to maintain this code myself. Is there a public issue I can follow or anything? 👀
m

matvei

11/16/2020, 12:32 PM
Here's the CL and there are two bugs linked in the commit message https://android-review.googlesource.com/c/platform/frameworks/support/+/1394667
❤️ 1
View count: 4