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

    Kyant

    10/31/2020, 11:42 PM
    Is there a way to make a blur
    Surface
    (foreground) or
    Image
    (itself)?
    r
    l
    6 replies · 3 participants
  • s

    Socheat KHAUV

    11/01/2020, 1:04 AM
    rememberCoroutineScope { <http://Dispatchers.IO|Dispatchers.IO> }
    
    i get the following error when build gradle
    
    org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't transform method node:
    z
    1 reply · 2 participants
  • s

    Samsruti Dash

    11/01/2020, 6:24 AM
    I wanted to preview the Scaffold. But I am not able to preview properly.
    1 reply · 1 participant
  • h

    Hitanshu Dhawan

    11/01/2020, 7:55 AM
    Hey, what’s the best way to achieve this kind of animation? Should I use
    IntPropKey()
    and set the x,y coordinates using
    Layout
    composable? or is there any better way of achieving this?
    20-10-31-13-14-15.mp4
    j
    2 replies · 2 participants
  • j

    jaqxues

    11/01/2020, 9:13 AM
    Is there any reason not to use Enums instead of sealed classes for defining screens? (https://developer.android.com/jetpack/compose/navigation#bottom-nav)
    m
    k
    5 replies · 3 participants
  • g

    gsala

    11/01/2020, 9:40 AM
    The example in https://developer.android.com/jetpack/compose/navigation#bottom-nav to integrate the new navigation and BottomNavView together doesn't work properly. Is it even right to model the "horizontal" navigation pattern of a bottom navigation menu, with a navigation backstack?
    device-2020-11-01-103324.mp4
    j
    i
    13 replies · 3 participants
  • k

    KamilH

    11/01/2020, 11:16 AM
    I get back to my
    compose
    project after a while, tried to compile a project and it is not compiling, I’m getting:
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:prepareDebugKotlinCompileTask'.
    > org/jetbrains/kotlin/gradle/tasks/KotlinCompile
    Seems like it’s something unexpected, because:
    Unable to load class 'org.jetbrains.kotlin.gradle.tasks.KotlinCompile'.
    
    This is an unexpected error. Please file a bug containing the idea.log file.
    but maybe someone else seen this already?
    2 replies · 1 participant
  • l

    loloof64

    11/01/2020, 12:33 PM
    Hi everyone ! Is there a simple way to write something like this
    60.dp.toPx()
    Inside a composable ?
    s
    m
    +2
    10 replies · 5 participants
  • j

    jaqxues

    11/01/2020, 2:45 PM
    Is there currently a way to use a 
    viewModel<ViewModelClass>()
     function to get a ViewModel in Compose with Hilt/Dagger? Something that i can use like  this
    @Composable
    inline fun <reified T: ViewModel> viewModel() =
        (ContextAmbient.current as MainActivity).viewModels<T>()
    
    @Composable
    fun Example() {
        val viewModel by viewModel<SomeViewModel>()
        viewModel.doStuff()
    }
    The above works, but it certainly is not elegant or safe or anything
    m
    i
    +3
    38 replies · 6 participants
  • r

    Robert Menke

    11/01/2020, 8:14 PM
    Does navigation-compose currently support nested `NavHost`s? My use case is that I have a sign up flow and I’d like to move to a bottom navigation view when the user signs in. Following the docs the
    Scaffold
    with bottom navigation uses a NavHostController to define each screen in the bottom navigation. When I declare my 2nd nav host I get the error
    java.lang.IllegalStateException: ViewModelStore should be set before setGraph call
    i
    4 replies · 2 participants
  • v

    Vinay Gaba

    11/01/2020, 9:36 PM
    this is the handler in question
    @Composable
    internal fun BackButtonHandler(onBackPressed: () -> Unit) {
        Providers(
            AmbientBackPressedDispatcher provides LifecycleOwnerAmbient.current as AppCompatActivity
        ) {
            handler {
                onBackPressed()
            }
        }
    }
    i
    10 replies · 2 participants
  • c

    Chethan

    11/02/2020, 4:44 AM
    Hi , Is there way that I can disable TextField . I have use case in which clicking on TextField should open DropDownMenu, Textfield should only take the click rather focus or opening keyboard, How can disabled focus and enable the click ? Is that possible ?
    a
    m
    2 replies · 3 participants
  • m

    Mahdi

    11/02/2020, 6:34 AM
    Hi. Why some components like
    OutlinedTextField
    Can not trigger clickable lambda? Even if I wrap it with Box it will same. Thanks
    1 reply · 1 participant
  • a

    Anita

    11/02/2020, 6:51 AM
    Do I need to import something in order to use Modifier.weight()? I'm using alpha06
    h
    3 replies · 2 participants
  • k

    Kshitij Patil

    11/02/2020, 7:54 AM
    what's the difference between
    canvas.drawLine
    and
    canvas.drawPath
    ? when to use one over the other?
    a
    2 replies · 2 participants
  • s

    Slackbot

    11/02/2020, 8:28 AM
    This message was deleted.
    a
    1 reply · 2 participants
  • n

    Neil

    11/02/2020, 9:44 AM
    Hi all, Just been trying LazyRowFor in alpha06. I’ve notice a problem when using a constraint layout in each item. In the constraint I have a background image, surface and logo image. They should be displayed in this order with the background image at the back and logo image at the front. The order the items are overlaid is now inconsistent as you scroll through the row. This worked ok in alpha02.
    rendering_order_bug.mp4
    h
    3 replies · 2 participants
  • i

    izyaboi

    11/02/2020, 10:49 AM
    one question about navigation compose how can i implement the navigation. I have a one activity app with navigation bottom an a detail that behavior like an actvity. but ive i implement the detail screen composable in the navhost without activity. The behavior is diffrent
    NavHost(navController, startDestination = NavigationScreen.Home.route) {
        composable(NavigationScreen.Home.route) { Home(navController) }
        composable(NavigationScreen.Playlist.route) { Playlist() }
        composable(Screen.Detail.route) { DetailScreen()}
    }
    navigation works but not like i implement it as second activity with start activity.
    l
    z
    10 replies · 3 participants
  • g

    Grigorii Yurkov

    11/02/2020, 2:34 PM
    What is
    map
    analog for
    MutableState
    ?
    a
    o
    34 replies · 3 participants
  • y

    Yuri

    11/02/2020, 2:55 PM
    I’ve tried to turn on
    newIR
    with
    1.4.20-RC
    on my project. Getting this compilation error with no details attached.
    e: java.lang.IncompatibleClassChangeError: Found class org.jetbrains.kotlin.ir.declarations.IrClass, but interface was expected
    	at androidx.compose.compiler.plugins.kotlin.VersionChecker.check(VersionChecker.kt:62)
    	at androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:40)
    	at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade$doGenerateFiles$1.invoke(JvmBackendFacade.kt:91)
    	at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade$doGenerateFiles$1.invoke(JvmBackendFacade.kt:40)
    	at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:95)
    How can I understand, what exact code causes this error?
    a
    1 reply · 2 participants
  • b

    Bryan Herbst

    11/02/2020, 3:07 PM
    TalkBack has a lot of behavior dependent on `AccessibilityNodeInfo`’s class name, and there’s some functionality in in Compose’s accessibility layer to map specific semantics to
    View
    classes (e.g.
    ProgressBar
    or
    SeekBar
    when
    SemanticsProperties.AccessibilityRangeInfo
    is present). However, this is missing for some prominent components such as
    Button
    , with no public API to influence that behavior. This behavior is also a bit clunky given that it relies on labeling Compose widgets as specific
    View
    classes. Is there a plan to surface something to support this? Is the TalkBack team exploring ways of decoupling TalkBack from the View APIs to better support Compose in the future?
    a
    6 replies · 2 participants
  • a

    Archie

    11/02/2020, 4:13 PM
    Hi @Ian Lake, I have this code where I don't want to show the
    BottomNavigation
    in the bottomBar of the
    Scaffold
    when I am in a certain screen (which for this sample code is ScreenC). But everytime I get to ScreenC, it goes ScreenC and immediately jumps back to startDestination, ScreenA. Am I doing something wrong here?
    @Composable
    fun Main() {
        SampleAppTheme {
            val navController = rememberNavController()
            val currentBackStackEntry by navController.currentBackStackEntryAsState()
    
            Scaffold(
                topBar = {
                    ...
                },
                bottomBar = {
                    val currentRoute = currentBackStackEntry?.arguments?.get(KEY_ROUTE)
                    if (currentRoute != ScreenC.route) {
                        BottomNavigation {
                            BottomNavigationItem(
                                icon = { Icon(Icons.Default.Home) },
                                selected = true,
                                onClick = {}
                            )
                            BottomNavigationItem(
                                icon = { Icon(Icons.Default.PieChart) },
                                selected = false,
                                onClick = {}
                            )
                            BottomNavigationItem(
                                    icon = { Icon(Icons.Default.Person) },
                                    selected = false,
                                    onClick = {}
                            )
                        }
                    }
                }
            ) {
                val modifier = Modifier.padding(it)
                NavHost(
                    navController = navController,
                    startDestination = ScreenA.route,
                ) {
                    composable(ScreenA.route) {
                        MyScreen(modifier, "A", "", "to B") {
                            navController.navigate(ScreenB.route)
                        }
                    }
                    composable(ScreenB.route) {
                        MyScreen(modifier, "B",  "", "to C") {
                            navController.navigate(ScreenC.route)
                        }
                    }
                    composable(ScreenC.route) {
                        MyScreen(modifier, "C",  "","to A") {
                            navController.navigate(ScreenA.route)
                        }
                    }
                }
            }
        }
    }
    20201103_000823.mp4
    i
    l
    10 replies · 3 participants
  • c

    Ciprian Grigor

    11/02/2020, 6:03 PM
    is there a way to check at runtime if compose is running in preview or in device/emulator?
    j
    g
    5 replies · 3 participants
  • k

    Kshitij Patil

    11/02/2020, 6:53 PM
    Canvas click events are not working once we wrap them inside a
    Composable
    Box(Modifier.fillMaxSize()) {
        Canvas(Modifier.clickable { Log.i(TAG, "Clicked") }) {
            drawCircle(Color.Red, 25f, Offset(150f,150f))
        }
    }
    I want only the portion of Circle clickable, I tried clipping the Canvas, didn't help. Canvas click events only work within
    Surface
    , that too, on the entire Canvas area.
    r
    a
    +1
    11 replies · 4 participants
  • d

    David Albers

    11/02/2020, 9:03 PM
    Is it possible to test Compose without running the test on a device/emulator?
    a
    c
    +2
    12 replies · 5 participants
  • s

    sashjakk

    11/02/2020, 10:00 PM
    🤔 any known compatibility issues exist with compose and new data store? Looks like enabling new IR backend breaks my app with
    e: java.lang.IllegalStateException: Backend Internal error: Exception during IR lowering
    a
    a
    3 replies · 3 participants
  • a

    alexandrepiveteau

    11/03/2020, 12:26 AM
    Is there a way to write a
    @Composable fun
    that is effectively inlined (and without a group) ? I have a UI with a flat hierarchy and would like to factorise some of the logic in different functions, knowing that exactly one of these will be called no matter what the input parameters are. The pattern I’d like to achieve is similar to this Gist : https://gist.github.com/alexandrepiveteau/47a18b29a6bd9cc2fcd2d347bc8f4a44. While looking into this, I’ve stumbled on
    @ComposableContract(readonly = true)
    , which “does not generate a group around the body of the function it annotates”, and I feel like is kind of what I’d need. However, the documentation clearly states that it is “not safe unless […] composer only executes read operations”. What’s exactly a “write” operation for a composer ? And is there a better way to achieve what I’m trying to do than using
    @ComposableContract(readonly = true)
    ?
    z
    c
    3 replies · 3 participants
  • d

    Daniele B

    11/03/2020, 1:53 AM
    I started to use the new
    navigation
    . Congratulations, it’s great! It’s much neater than the one in SwiftUI. I also like the fact that it uses URIs, which makes it very adaptable to the Web too. But maybe there is still some room for improvement. For example, I find rather verbose the way to collect string arguments. Having to repeat the parameter name twice doesn’t feel optimum.
    NavHost(navController, startDestination = "master") {
        .....
        composable("detail/{item}") { backStackEntry ->
            val detailName = backStackEntry.arguments?.getString("item")!!
            DetailView(appState = appState, detailName = detailName)
        }
    }
    i
    s
    13 replies · 3 participants
  • z

    Zach Klippenstein (he/him) [MOD]

    11/03/2020, 2:15 AM
    I’m curious if anyone has ran into this bug. It’s pretty weird, but it’s consistent: https://issuetracker.google.com/issues/172268023
    l
    9 replies · 2 participants
  • g

    Guy Bieber

    11/03/2020, 3:20 AM
    Does compose support the standard sharing button in android? Does anyone have an exampl.e
    a
    d
    +2
    5 replies · 5 participants
Powered by Linen
Title
g

Guy Bieber

11/03/2020, 3:20 AM
Does compose support the standard sharing button in android? Does anyone have an exampl.e
a

Alexjlockwood

11/03/2020, 3:52 AM
what do you mean by “the standard sharing button”?
d

Daniele B

11/03/2020, 4:26 AM
maybe he meant, the standard sharing dialog?
👍 1
s

Sergey Y.

11/03/2020, 8:21 AM
It is not related to Compose UI.
Sharing Intent
is an API of the Android SDK.
https://developer.android.com/training/sharing/send
👍 1
n

nickbutcher

11/03/2020, 8:52 AM
Here's an example: https://github.com/android/compose-samples/blob/main/JetNews/app/src/main/java/com/example/jetnews/ui/article/ArticleScreen.kt#L186-L189
👍 1
View count: 3