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

    Napa Ram

    08/17/2021, 5:47 PM
    Hello Everyone i have one scenario i have one library which is called as UI library in which i create common UI which is reusable for entire project lets say i have one component where i can search country using XML approach I will create one XML(search_listing_view.xmml) for listing country for recyclerview layout and another xml(search_layout.xml) where i am adding recyclererView and on top i am adding Search Field for filter now in contact details library i will use search field override XML if i want to change UI of search_listing_view.xml then i will create xml file with same name in contact details library then in xml i will change listing View How can i achieve overriding UI in Compose?
    a
    • 2
    • 1
  • m

    Mohamed Ibrahim

    08/17/2021, 8:04 PM
    I have two behaviors of an animation due to Flow setup code, the only difference is how I launch Flow, code in thread.
    c
    d
    • 3
    • 6
  • c

    Colton Idle

    08/17/2021, 10:30 PM
    Some rather embarrassing code ahead, but I'm trying to write a fairly simply container around my app content that intercepts click and triggers a navigate action on triple click under 500ms. The problem is that my code hangs and sometimes causes an ANR. Can I get some 👀 on it as a bit of code review?
    l
    • 2
    • 7
  • r

    robnik

    08/17/2021, 10:37 PM
    Is there a way to get a
    Text
    to stay centered when it overflows. My label in
    BottomNavigationItem
    is overflowing a bit, but going off-center to the right. Image in thread.
    c
    l
    • 3
    • 7
  • i

    Ink

    08/17/2021, 11:05 PM
    Column {
        Row()
        LazyColumn()
    }
    How Can I make my Row scrollable? I want to scroll Row in the same time when I'm scrolling LazyColumn
    l
    a
    • 3
    • 4
  • a

    Alexander Black

    08/18/2021, 12:15 AM
    How can I mix LazyVerticalGrid with a LazyColumn view? I’m trying to have image Carousels and then a grid view below, but I get this error message if I try to mix the two:
    java.lang.IllegalStateException: Nesting scrollable in the same direction layouts like LazyColumn and Column(Modifier.verticalScroll()) is not allowed. If you want to add a header before the list of items please take a look on LazyColumn component which has a DSL api which allows to first add a header via item() function and then the list of items via items().
    here’s my code so far:
    Column {
            SearchViewSearchBarInactive({})
            LazyColumn {
                item { Carousel(books, "New York Times Best Sellers") } // this is a lazy row with images in it
                item { Carousel(books, "Award Winning") }
                item { Carousel(books, "Note Worthy Performances") }
                item { Carousel(books, "Trending") }
                item {
                    Text("Categories",
                        style = MaterialTheme.typography.h3,
                        modifier = Modifier.padding(start = 8.dp, top = 32.dp, bottom = 10.dp),
                        color = MyAppTheme.colors.textPrimary)
                }
                item { CategoryView() } // this is my grid view
            }
        }
    l
    • 2
    • 3
  • c

    Colton Idle

    08/18/2021, 1:31 AM
    I have a bottom sheet in it's default open height (about half way up the screen) and I have a title aligned to the top in the middle. It looks and works great, but when the card is fully expanded, the title is under the status bar ever so slightly. "I know. I'll use accompanist insets to apply statusBarPadding()!" And yes, that works, but now my card in the default open height (half way open) now has wayyy too much padding in that state, but it looks great in the full expanded state. How do I go about solving this so that there is no padding in the default open state, but the extra padding is there during the fully open state?
    a
    d
    • 3
    • 8
  • s

    Scott Kruse

    08/18/2021, 3:08 AM
    Has anyone had experience with
    Arrangement.SpaceBetween
    ? Im trying to left align Text, and right align another Text. The problem is my left aligned text can be long, and it's causing my right aligned text to wrap or be hidden completely
    a
    w
    • 3
    • 2
  • n

    Napa Ram

    08/18/2021, 4:02 AM
    I want to start timer as soon as activity start but it keep on starting again and again attached video also for reference and code
    VID_20210818_092728.mp4
    c
    u
    • 3
    • 6
  • n

    Nikola Milovic

    08/18/2021, 7:09 AM
    Hello everyone, I am guessing there's something to the way remember works but I cannot make this work. My use case, load the profile from the backend and display it on the screen. Now when I first initialize the model for my composable I use dummy default values. Afterward, the backend fetches the profile and I want to render the new values. But it seems that even tho the composable gets recomposed, the remember values don't get updated (I guess that should happen lol). How can I go about this?
    val model by component.models.subscribeAsState()
    
    val profile = model.profile
    
    val about = remember { mutableStateOf(TextFieldValue(profile.about)) }
    val email = remember { mutableStateOf(TextFieldValue(profile.email)) }
    Firstly the values for about and email are "" empty string but later on they get updated and the state updates. Is there a way to achieve this behaviour? As I need this values later on for values in my textfields
    TextField(
                value = email.value,
                onValueChange = { email.value = it },
                label = { Text("Email") },
                readOnly = !isEditing
            )
    l
    • 2
    • 3
  • v

    Vitaliy Zarubin

    08/18/2021, 8:55 AM
    Can you tell me what could be the problem when connecting Сoil?
    Execution failed for task ':app:checkDebugDuplicateClasses'.
    c
    • 2
    • 3
  • f

    Florian

    08/18/2021, 10:27 AM
    What text color property from the MaterialTheme can I use on this background color? I don't want to hardcode Black. (That's the default background of a LinearProgressIndicator) Does
    onBackground
    make sense?
    a
    • 2
    • 2
  • r

    rajesh

    08/18/2021, 10:52 AM
    This is rather simple question: I've one (child) compose screen which gets its argument from parent composable. I want to use that property to call a ViewModel function when child composable screen gets created. Where should I make that function call? Randomly inside composable? Inside
    remember
    ?
    a
    c
    • 3
    • 5
  • r

    rajesh

    08/18/2021, 11:41 AM
    Is there any way to let compose know that composable1() should be placed in upper half of screen and composable2() should be placed in lower half of screen (like instagram profile page), no matter at what time data arrive from network. (post data could arrive before user data)
    t
    c
    t
    • 4
    • 6
  • u

    Utkarsh Tiwari

    08/18/2021, 12:04 PM
    I am trying to intercept clicks on a text to change the text colors. Both click and color work as expected. However, because of this interception,
    talkback a11y
    doesn't focus on the text anymore. Doesn't anyone know what could be wrong with this approach?
    var isTextPressed by remember { mutableStateOf(false) }
    Text(
        modifier = Modifier
            .pointerInput(Unit) {
                detectTapGestures(
                    onPress = {
                        isTextPressed = true
                        if (tryAwaitRelease()) {
                            isTextPressed = false
                        }
                    },
                    onTap = {
                        onClick.invoke()
                    }
                )
            }
        ...
        ...
    )
    t
    • 2
    • 5
  • m

    Marcin Środa

    08/18/2021, 12:23 PM
    How to combine clickable actions on parent and children?
    ➕ 1
    t
    c
    +2
    • 5
    • 15
  • a

    Ali Kabiri

    08/18/2021, 1:03 PM
    Hey there 🙂 Does anyone know a neat way to make screenshots of composables?
    d
    c
    +2
    • 5
    • 21
  • t

    tylerwilson

    08/18/2021, 2:17 PM
    So, I have built a UI in Compose for Android. It is a collection of vertical scrolling composables in a horizontal scrolling lazyrow. Think a schedule component. Two items: 1. The horizontal scroll performance is very bad. I will also try a non-Lazy column. But I am curious if people have pointers on how to profile this? 2. I would like to scroll all vertical components together. Anybody have an example of how to scroll columns together?
    a
    s
    • 3
    • 3
  • s

    Sergey Y.

    08/18/2021, 2:40 PM
    Working with custom widgets in Compose, I caught myself with constant
    dp->px
    and
    px->dp
    transformations. Because the Layout system works with
    Dp
    and the Canvas system accepts
    Px
    . Are there any recommendations or best practices on how to reduce the conversion of these units? Reduce repeatability of the code. The more they used in the code, the more it adds noise. 🧵
    a
    a
    m
    • 4
    • 5
  • v

    VitalNik

    08/18/2021, 2:46 PM
    Hi all! What would be the best approach for deep linking to the content that requires authentication? For example: deep linking to a user's profile page. For now I can manually handle that kind of links, not using
    deepLinks
    list from
    Composable
    at all and it does not seem right. Thanks!
    c
    • 2
    • 3
  • a

    Andrew Leung

    08/18/2021, 3:45 PM
    Hello, is it possible to do function param injection on a Composable using Hilt?
    r
    c
    j
    • 4
    • 19
  • o

    Orhan Tozan

    08/18/2021, 3:57 PM
    Where can we see Compose's supported Kotlin version?
    c
    e
    • 3
    • 4
  • c

    Chachako

    08/18/2021, 4:31 PM
    A little curious about the compatibility of compiler plugin, why can’t Kotlin provide a stable compiler plugin interface so that compose doesn’t have to worry about compatibility often
    j
    • 2
    • 1
  • c

    Colton Idle

    08/18/2021, 5:46 PM
    I'm trying to recreate this airbnb carousel using Accompanist Pager. My code works/looks pretty much perfectly BUT the pager doesn't have padding on the left side (like the image shows)
    c
    • 2
    • 13
  • v

    Vsevolod Kaganovych

    08/18/2021, 6:34 PM
    Hi. I have a
    TextField
    with label. I want to change the
    fontSize
    of label but leave the behaviour that it becomes smaller when it floats to the top. If I change font size, the animation of decreasing size is gone and label has the same size in focused and unfocused mode. But if I don't set manually
    fontSize
    , everything works as expected. Any suggestions? Code in thread.
    a
    • 2
    • 2
  • c

    Colton Idle

    08/18/2021, 8:00 PM
    I have an app that has a Home screen, but kicks you to the SignIn screen if userManager.isLoggedIn == false. This works fine, but my bottom nav also works based off of whether or not I'm on the Home screen. Problem: The bottomNav flashes on the screen on a cold start In my test, I made my Home screen a Box(filledMaxSize with background Red), and it does NOT show/flicker when I launch the app. The only thing that flickers onto the screen is the bottomNav. It is very minor but I was wondering if there's something I can do to improve this?
    @Composable
    fun MyBottomNav(navController: NavController, items: List<Screen>, userManager: UserManager
    ) {
        val navBackStackEntry by navController.currentBackStackEntryAsState()
        val currentDestination = navBackStackEntry?.destination
    
        if(currentDestination?.hierarchy?.any { it.route == Screen.Home.route } == true) {
            BottomNavigation(...
    n
    • 2
    • 7
  • f

    Florian

    08/18/2021, 10:15 PM
    how could I draw only the parts of the text that are on top of the darker, filled background in white and the rest in black?
    c
    l
    a
    • 4
    • 14
  • s

    Smorg

    08/18/2021, 10:25 PM
    My
    hiltViewModel
    calls (from the
    androidx.hilt.naviagtion.compose
    lib) returns a new instance of the retrieved viewmodel as opposed to returning the same viewmodel scoped to a navigation graph where it is first retrieved. Any ideas what I might be missing?
    c
    a
    • 3
    • 5
  • r

    rnett

    08/19/2021, 1:01 AM
    I want to be able to pick up and drag one element into a "container" element, i.e. moving files around in folders in AS or IntelliJ. Dragging is supported fine, but detecting when something is dropped on the current composable seems hard (looking for enter/exit doesn't work since
    detectDragGesturesAfterLongPress
    consumes the position change events). Is there any support for this I'm not seeing, or has anyone implemented anything similar?
    t
    • 2
    • 1
  • d

    darkmoon_uk

    08/19/2021, 2:08 AM
    focusable(...)
    does not seem to be working as advertised? I'm trying to make a
    Box
    (or
    Surface
    - I'm not fussy 😁) be focusable so have modified it to: • be
    .focusable(true)
    ✅ • have a
    focusOrder(myFocusRequester)
    ✅ Documentation suggests this is all we need for a custom composable to be focused, and yet, when I call
    requestFocus()
    on my `Box`'s focus requester, the previously focused component (a regular
    TextField
    ) does not appear to 'let go' of it's focus, also TalkBack does not shift it's highlight to the
    Box
    component. What else do I need to do to effect a full transfer of focus over to my custom component?
    r
    • 2
    • 3
Powered by Linen
Title
d

darkmoon_uk

08/19/2021, 2:08 AM
focusable(...)
does not seem to be working as advertised? I'm trying to make a
Box
(or
Surface
- I'm not fussy 😁) be focusable so have modified it to: • be
.focusable(true)
✅ • have a
focusOrder(myFocusRequester)
✅ Documentation suggests this is all we need for a custom composable to be focused, and yet, when I call
requestFocus()
on my `Box`'s focus requester, the previously focused component (a regular
TextField
) does not appear to 'let go' of it's focus, also TalkBack does not shift it's highlight to the
Box
component. What else do I need to do to effect a full transfer of focus over to my custom component?
r

rnett

08/19/2021, 2:28 AM
Make sure you're putting the
focusOrder
first, that's gotten me a couple of times.
:thank-you: 1
👀 3
🙏 1
d

darkmoon_uk

08/19/2021, 2:37 AM
...that was it. @rnett thank you!
This feels like such an obvious gotcha for devs trying to use these two modifiers in combination; it really would be quite easy to include in the API comments. Not proud to admit this probably cost me a day 😞
👍 2
🤗 1
View count: 3