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

    Stylianos Gakis

    08/31/2021, 2:12 AM
    Having some trouble using compose navigation with multiple bottom navbar backstack support. Details in Thread 🧵
    i
    • 2
    • 6
  • f

    Felix Schütz

    08/31/2021, 6:52 AM
    Does anybody know a tutorial about creating your own nav host / nav controller / navigator?
    j
    • 2
    • 2
  • s

    Stefan Oltmann

    08/31/2021, 6:59 AM
    If the first Text is too wide it shrinks my second Text. Instead of "9999" only one "9" is shown for example. How can I achieve that the second Text always takes the required space and the first Text get's shrinked/overflows if there is not enough space? I tried
    defaultMinSize
    , but that has not the effect I expected.
    Row(
        verticalAlignment = Alignment.CenterVertically
    ) {
    
        Text(
            text = text
        )
    
        Spacer(
            modifier = Modifier.weight(1.0f)
        )
    
        Text(
            text = photoCount.toString(),
            maxLines = 1,
            modifier = Modifier.padding(horizontal = defaultPadding).border(1.dp, Color.Red)
        )
    }
    👀 1
    ✅ 1
    m
    a
    • 3
    • 6
  • a

    Anders Kielsholm

    08/31/2021, 8:25 AM
    Hi 🙂 I have a strange issue with
    DropdownMenu
    and I don't know if it's me doing something wrong. I want the `DropdownMenuItem`s to contain an icon and text. It however seems like the width of the items are based on the text solely and not the combined width. I have this implementation as an example (in the
    actions
    part of a
    TopAppBar
    ):
    IconButton(onClick = { showMenu = !showMenu }) {
        Icon(<http://Icons.Default.Menu|Icons.Default.Menu>, contentDescription = null)
    }
    
    DropdownMenu(
        expanded = showMenu,
        onDismissRequest = { showMenu = false }
    ) {
        DropdownMenuItem(
            onClick = { }
        ) {
            Icon(Icons.Default.ThumbUp, contentDescription = null)
            Text("This is a line", maxLines = 1)
        }
        DropdownMenuItem(
            onClick = { }
        ) {
            Icon(Icons.Default.Clear, contentDescription = null)
            Text("This is another line", maxLines = 1)
        }
    }
    I've attached some Screenshots. The first is how it looks with the above implementation (see the second line is cut off). The second is how it looks without the icons - notice how the width of the box is exactly the same as the first. The third is how I want it to look in the end (I achieved this by setting a static with on one of the `Text`s to 170 dp). Does anyone know what I'm doing wrong - or could it be a bug?
    👀 1
    ✅ 1
    f
    a
    s
    • 4
    • 9
  • t

    Tin Tran

    08/31/2021, 8:54 AM
    Hi! How do I create different instances of a ViewModel on the same destination?
    composable(route = "a") {
        Component1(hiltViewModel())
        Component1(hiltViewModel())
    }
    a
    j
    • 3
    • 6
  • e

    Erlich

    08/31/2021, 2:35 PM
    How does Compose draws the UI, does it uses
    View
    class internally to draw the UI.
    a
    • 2
    • 1
  • r

    rsktash

    08/31/2021, 3:08 PM
    Hi, how can we change imeAction label text?
    a
    f
    • 3
    • 8
  • c

    Cicero

    08/31/2021, 3:10 PM
    Hey, I was going to write a post here but I wrote it on Medium: Stripping theme.xml for a more compose approach
    c
    j
    k
    • 4
    • 12
  • d

    deviant

    08/31/2021, 3:42 PM
    guys, is it posible to automate
    contentDescription
    generation for every composable in the project?
    modifier = Modifier.semantics {
          contentDescription = "back button"
        }
    maybe with reflection or some AOP tool? ideally i would name each contentDescription with a current composable function name
    b
    • 2
    • 4
  • a

    Angeles Bilbao

    08/31/2021, 5:53 PM
    Hi all! Do you know if there is a way to get all the material icons into my app? I want to allow the user to choose any icon from the categories(filled, rounded, sharp, etc.) I was considering using reflection but I think that would consume a lot of time and resources
    ➕ 1
    m
    • 2
    • 2
  • s

    Scott Kruse

    08/31/2021, 6:26 PM
    Does anyone know if Espresso UI testing will work with compose? Whats the plan for UI testing compose driven layouts?
    z
    • 2
    • 2
  • m

    mkrussel

    08/31/2021, 7:00 PM
    Is there any support for the Material Slider concept of floating value label.
    f
    s
    • 3
    • 5
  • s

    Sanendak

    08/31/2021, 7:54 PM
    Does the navigation-compose support multiple backstack for bottomNavigation? I tried example from developer.android.com, but tabs doesn't saves it's state
    f
    s
    d
    • 4
    • 11
  • s

    Stylianos Gakis

    08/31/2021, 8:24 PM
    Hey people, I recently used
    @Preview
    extensively and I would say that providing all the fake data sometimes gets repetitive. Doing for example
    getFakeUserModel(id)
    functions work great, but… where do you put those? Where in the package structure do you put your fake preview data? And polluting every class with something like
    data class Whatever(...) {
        companion object {
            fakePreviewWhatever(something: String): Whatever
        }
    }
    is not necessarily something that I love doing. At the rate that I am doing it now, a big chunk of my files in the package structure would need to be there just to provide fake models which sounds like a great way to confuse newcomers to the codebase. Any tips or tricks on how to do this better?
    f
    w
    +2
    • 5
    • 9
  • t

    tad

    08/31/2021, 9:09 PM
    Any plans to hook up
    Surface
    to Compose? Would be useful for, say, camerax.
    r
    • 2
    • 14
  • s

    Sanendak

    08/31/2021, 10:18 PM
    Seems if startDestination in NavHost isn't a BottomNavScreen it breaks backstack
    i
    c
    • 3
    • 8
  • n

    Napa Ram

    09/01/2021, 5:15 AM
    Hi Everyone, We are not able to do Appium Testing as i am not able to find view in appium, earlier we use to find view by ID but as of now we don't have id. Is there any support for appium or any work around
    k
    z
    j
    • 4
    • 7
  • n

    Nipun Rajput

    09/01/2021, 6:38 AM
    I am trying to get rid of underline while typing in textfield, Any help?
    a
    a
    +2
    • 5
    • 18
  • m

    Mjahangiry75

    09/01/2021, 1:36 PM
    Why does AdView cause memory leak? code is in thread
    w
    g
    • 3
    • 13
  • m

    Mohamed Ibrahim

    09/01/2021, 2:31 PM
    What’s the Canvas function to draw such path?
    a
    • 2
    • 2
  • r

    robnik

    09/01/2021, 5:25 PM
    How do you make a LazyColumn reset scroll to zero when a model changes? Code in thread is not working.
    n
    • 2
    • 4
  • s

    Sergey B

    09/01/2021, 7:30 PM
    glad to see the glow effect for scroll https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.1.0-alpha03 🔥 awesome job
    ❤️ 4
    🔥 1
    :party-parrot: 5
    a
    f
    • 3
    • 2
  • c

    Chris Johnson

    09/01/2021, 7:43 PM
    Is there a known way to only show elevation on the bottom of a particular composable? I have a Surface that I want to have elevation, but it's also showing elevation on the top as well. Although ever so slightly. The basic layout for this is
    Column {
        TopAppBar(){}
        Divider()
        Surface() {} // Essentially an elevated Row. Picture below
        Content() {}
    }
    b
    • 2
    • 4
  • n

    Nthily

    09/01/2021, 9:59 PM
    Hi there, im using
    jetpack compose navigation
    , I want to ask when I use
    Navigate with arguments
    it will go back to the previous page by clicking the back button on the phone, but if I want to make a back button inside this interface and also go back to the previous page, how should I do it?
    i
    • 2
    • 3
  • m

    Mohammad Jahidul Islam

    09/02/2021, 4:34 AM
    :kotlin-intensifies: Anyone use chrome custom tab in compose?
    :kotlin: 1
    g
    • 2
    • 1
  • j

    Justin Yue

    09/02/2021, 6:30 AM
    I was updating to the latest jetpack compose navigation dependency by including this line,
    implementation "androidx.navigation:navigation-compose:2.4.0-alpha08"
    in my build.gradle. Sync works fine, but when I try to build, I get this error (in thread) stating that min sdk is not 31. I'm a bit confused by this since sdk 31 is android 12, which hasn't come out yet? Edit: Resolved!
    m
    c
    • 3
    • 6
  • g

    galex

    09/02/2021, 7:05 AM
    Hello, I am trying to make an enum with references to Colors from my theme!
    enum class Hierarchy(
        backgroundColor: Color,
        contentColor: Color,
        pressedBackgroundColor: Color,
        pressedContentColor: Color,
        disabledBackgroundColor: Color,
        disabledContentColor: Color,
        border: BorderStroke? = null,
    ) {
    
        Primary(
            backgroundColor = MyTheme.colors.accentDefault,
            contentColor = MyTheme.colors.contentInverse,
            disabledBackgroundColor = MyTheme.colors.accentDisabled,
            disabledContentColor = MyTheme.colors.contentInverse)
    }
    But as the enum is not a Composable I am hit with an error
    @Composable invocations can only happen from the context of a @Composable function
    . Is there a workaround this error?
    l
    c
    a
    • 4
    • 6
  • f

    Felix Schütz

    09/02/2021, 8:40 AM
    When using Coil to load videos from URIs generated with
    ContentResolver
    , I need to explicitly pass the fetcher to the request builder, otherwise Coil cannot process the video (since the URI does not contain the file type). E.g.:
    Image(
        painter = rememberImagePainter(
            data = contentUri,
            builder = {
                fetcher(VideoFrameUriFetcher(LocalContext.current))
            },
        ),
        contentDescription = null,
    )
    Creating the
    VideoFrameUriFetcher
    instance for every video seems kind of inefficient. Is there a better Compose way?
    a
    • 2
    • 3
  • m

    mario

    09/02/2021, 9:48 AM
    👋 Hello, Any good article where navigation from the viewmodel is included? I'm definitely getting headaches from this. 🙏 A flow and a sealed class make that if I press return I immediately go forward again.
    p
    • 2
    • 1
  • k

    K Merle

    09/02/2021, 11:40 AM
    Is there any documentation on how to handle
    delay
    inside
    LaunchedEffect
    coroutine scope in androidTests? I am unable to test if following lambda has been called when
    delay
    is present.
    LaunchedEffect(Unit){
        delay(splashTime)
        navigate(viewModel.isAuthenticated())
    }
    z
    r
    • 3
    • 5
Powered by Linen
Title
k

K Merle

09/02/2021, 11:40 AM
Is there any documentation on how to handle
delay
inside
LaunchedEffect
coroutine scope in androidTests? I am unable to test if following lambda has been called when
delay
is present.
LaunchedEffect(Unit){
    delay(splashTime)
    navigate(viewModel.isAuthenticated())
}
runBlockingTest
and
advanceTimeBy()
do not help.
z

Zach Klippenstein (he/him) [MOD]

09/02/2021, 1:53 PM
I think you can use the `ComposeTestRule`’s
mainClock
to control time on compose coroutines. https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule
k

K Merle

09/02/2021, 2:04 PM
This works. Thanks.
r

Rekha

09/02/2021, 7:34 PM
@K Merle what did you try? Are you getting composenotidle exception?
k

K Merle

09/02/2021, 8:41 PM
No, I've just advanced clock for
splashTime
and it works.
View count: 1