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

    Vsevolod Ganin

    06/13/2021, 3:11 PM
    I have an issue with a
    Slider
    in scrollable list. When I start to scroll the list and hit slider’s track in the way, the thumb jumps to that position immediately and scroll also happens. Is there a way to workaround this problem? For example, for buttons such problem doesn’t exist. When I hit button when starting to drag, it doesn’t actually trigger
    onClick
    (the ripple effect is rendered anyway though).
    m
    • 2
    • 3
  • a

    andriydruk

    06/13/2021, 6:22 PM
    Hi 👋 Is there any way to draw compose to bitmap? I tried to put Compose in View and use Bitmap canvas to draw View. I got a mess with backgrounds in bitmap but the same View was drawn properly on display 😬
    t
    • 2
    • 2
  • c

    chansek

    06/13/2021, 6:30 PM
    I am trying to make a single item clickable list. But the radio button never show selected until I scroll the items. Any help? https://stackoverflow.com/questions/67961422/lazycolumn-item-with-radiobutton
    d
    a
    • 3
    • 6
  • i

    Ink

    06/13/2021, 7:35 PM
    Hi guys. My app architecture looks like: viewModel + Compose layout per screen. In my viewModels I have Channel() where I handle actions from screen:
    init {
      viewModelScope.launch {
                try {
                    actions.receiveAsFlow().collect { action ->
                        when (action) {
                                        //handle actions here
                       }
                  }
            }
    }
    In
    Home screen
    I have list with post. The problem is when I select post and navigate user to
    PostDetails screen
    I can choose another post though list with post is underhood. I think it's related to
    Home viewModel
    and that action flow works in the background. Any solution what should I change?
    video-1623611633.mp4
    t
    i
    • 3
    • 4
  • d

    Daniel

    06/13/2021, 9:58 PM
    Is binding the current value of a piece of state to a local variable so that the compiler can infer it isn't null a valid pattern, or is there a better way to do this?
    val trackSettingsState = repo.trackSettings().collectAsState(initialValue = null)
    val trackSettings = trackSettingsState.value
    
    if (trackSettings == null) {
       Spinner()
    }
    
    TextField(trackSettings.frequency, /* ... */)
    Text(trackSettings.name)
    I could also use a with statement or an else branch, but I prefer handling the null-case up front and then being able to assume it isn't null later
    z
    • 2
    • 1
  • n

    Nicolas Acart

    06/14/2021, 12:23 AM
    Hi there, how do you detect soft keyboard visibility changes? On stack overflow some solutions are using the global layout listener, but I really don't like this solution because this method is called many times. The only "good" solution I have found is to use WindowInsets in the onCreate method of my main activity:
    ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { _, insets ->
        val isKeyboardVisible = insets.isVisible(WindowInsetsCompat.Type.ime())
        onSoftKeyboardVisibilityChange(isKeyboardVisible)// own method which notifies me of changes
        insets
    }
    This way worked in the emulator (Pixel 3a API 30) but not on my phone (Galaxy S8 API 28) On top of that after launching my app, I noticed that my statusBarColor and navigationBarColor from themes.xml no longer work (status and nav bars are white or dark according to the theme instead of my own colors set in themes.xml) I tried to change
    window.navigationBarColor
    and
    window.statusBarColor
    in the setContent without success I don't understand what's going on. Is it possible to have an explanation ?
    i
    c
    • 3
    • 6
  • y

    YASAN

    06/14/2021, 1:56 AM
    Is there a way to automatically rotate Icons when the device is using a RTL language? I can turn on
    AutoMirror
    for my own vector drawables but cant find a way to do that for Material Icons
    n
    • 2
    • 1
  • r

    Ryan Simon

    06/14/2021, 3:41 AM
    Hey all, I’m currently working with accompanist and the insets libraries, and it’s mostly doing what I want. Though I ran into a particular use case where passing padding from the insets-ui
    Scaffold
    to a child
    Composable
    isn’t very obvious More info in the thread…
    i
    • 2
    • 32
  • g

    gitai

    06/14/2021, 10:31 AM
    Hi, I started reading the ‘Foundation’ articles and I’m having some difficulties in understanding how things build up from source code to runtime execution. Specifically, consider the following quotes: “In Compose's declarative approach, widgets are relatively stateless and do not expose setter or getter functions. In fact, ***widgets are not exposed as objects.***” “Composition: a description of the UI built by Jetpack Compose when it executes composables.” “remember (composable) stores objects in the Composition, and forgets the object when the ***composable*** that called remember is removed from the Composition.” What exactly does the Compose compiler produce when parsing a @Composable annotated function ? Does it generate a class for each function that gets instantiated at runtime as node in the UI object tree ?
    f
    • 2
    • 3
  • a

    Alexander Sitnikov

    06/14/2021, 11:27 AM
    Does this mean that the next version of Compose cannot be used with AGP 4.2?
    a
    • 2
    • 1
  • a

    adauguet

    06/14/2021, 12:14 PM
    Is there an empty element in compose?
    a
    n
    +2
    • 5
    • 10
  • d

    divid3d

    06/14/2021, 12:30 PM
    Hi. Is there any possibility to disable dragging in
    ModalBottomSheetLayout
    ? I'm looking for solution that would allow to hide bottom sheet only programmatically.
    d
    c
    • 3
    • 9
  • e

    Erlan Amanatov

    06/14/2021, 12:54 PM
    I need to fill the remaining space in
    Column
    with an image but with a limit of its height. My code looks like
    Column{
    item1()
    item2()
    Image(Modifier.weight(1f))
    item3()
    ..
    )
    For small screens it works fine, but on bigger screens it takes too much space. So I need to limit the height of the image somehow.
    n
    h
    c
    • 4
    • 7
  • r

    Richard Z

    06/14/2021, 1:54 PM
    Does anybody know if there’s a way to force a compositing layer for a composable without a hack like setting alpha to 99%?
    a
    a
    • 3
    • 6
  • v

    Vinícius Santos

    06/14/2021, 2:16 PM
    There is any way i can scroll to a specific item inside a LazyColumn ?
    a
    k
    • 3
    • 2
  • a

    adauguet

    06/14/2021, 3:45 PM
    I am trying to pass Parcelable from master to detail view. I found out that
    arguments
    is null when I use
    putParcelable
    so I first have to instantiate it with
    Bundle()
    . Am I doing something wrong? I do not see any example with this mention ...
    d
    • 2
    • 1
  • c

    Chris Johnson

    06/14/2021, 4:27 PM
    Has anyone run into an issue where their TextField won't get focus from a DisposableEffect in beta-08? I'm trying to focus the TextField on fragment start but when I check the focus it says it's not focused. I'm using a FocusRequester and made sure nothing should be interfering in it receiving focus. It pops the keyboard up but the cursor isn't there which means its not active. It works fine if requested from a button click or some event firing... but on initial composition it seems there's a bug with this
    DisposableEffect(Unit) {
        focusRequester.requestFocus()
        onDispose { }
    }
    t
    a
    • 3
    • 8
  • j

    Jesse Hill

    06/14/2021, 6:26 PM
    This is kind of a compose question and kind of an android question. The compose app I’m working on recently underwent security testing and one of the issues brought up was
    Activity androidx.compose.ui.tooling.preview.PreviewActivity is not protected [android:exported=true]
    . I was trying to find out why it’s important for the
    PreviewActivity
    to be exported or if I can make it not exported for my project. As far as I can tell setting
    android:exported=false
    for the
    PreviewActivity
    only affects deploying a
    @Preview
    to the device. Will making this change have any negative effects on a release build of the app? If this is a non-issue, is there a link to release notes/documentation as to why it isn’t an issue?
    a
    n
    • 3
    • 3
  • m

    Mohamed Ibrahim

    06/14/2021, 8:07 PM
    in a full complete compose app, where strings will be saved, in Strings.kt as const or what, if this is the case what about the Localization part, pardon my ignorance if it was a basic question but I just got started
    z
    a
    +2
    • 5
    • 12
  • c

    Can

    06/15/2021, 7:45 AM
    Hey folks 👋 - we’re currently porting our design system from views to compose and I’m kinda missing the equivalent of
    firstBaselineToTopHeight
    in the compose world. I would’ve expected it near
    lineHeight
    in a
    TextStyle
    . Is it currently missing and is there any chance this will be supported any time soon? 🙂
    e
    a
    • 3
    • 5
  • a

    Akram Bensalem

    06/15/2021, 7:56 AM
    I'm currently use "TabRow" and "HorizontalPager" I wonder how to scroll the Tab idicator when switching from screen to another screen 🤔🤔
    a
    • 2
    • 2
  • n

    nitrog42

    06/15/2021, 9:21 AM
    Hey I have a quick question how something bothering me for some time assuming :
    val pagerState = rememberPagerState(pageCount = 2)
    can we write
    val selectedTabIndex = pagerState.currentPage
    TabRow(selectedTabIndex = selectedTabIndex,...)
    or do we have to do :
    val selectedTabIndex = remember(pagerState) { pagerState.currentPage }
    ?
    a
    c
    +2
    • 5
    • 8
  • d

    dimsuz

    06/15/2021, 2:09 PM
    If I have a transitive
    remember
    's which are initialized with values of
    State<T>
    , will they be re-memoized on state changes? This sounds quite entangled, that's because I need some clarity on this 🙂 Please see thread, with bottom-sheet related example.
    v
    • 2
    • 9
  • n

    nglauber

    06/15/2021, 2:19 PM
    I’m impressed that I found no reference for
    RelocationRequester
    here in the channel 😄 I have a
    Column
    with several
    TextField
    . When I tap on a
    TextField
    at the bottom of the screen, the keyboard is opened and I want that field be positioned just above the keyboard. I thought that
    RelocationRequester
    resolves this problem…
    a
    d
    • 3
    • 6
  • h

    Hachemi Hamadi

    06/15/2021, 3:20 PM
    I have a
    class ProjectsViewModel : ViewModel()
    and i already called it in a component using :
    val projectsViewModel: ProjectsViewModel = viewModel()
    and when i navigate (using Navigation Component) and try to get the model using the same viewModel through different components ? Or should i declare the instance in the top of my code and pass it to different component that need access to it ?
    i
    • 2
    • 1
  • r

    rajesh

    06/15/2021, 4:50 PM
    I've multiple network requests in single screen having different observers as below
    val user by remember(profileViewModel) { profileViewModel.user }.collectAsState()
    val posts by remember(profileViewModel) { profileViewModel.posts }.collectAsState()
    
    when (user) {
    	is UiState.Loading -> {
    		CircularProgressIndicator(
    			modifier = Modifier.wrapContentWidth(CenterHorizontally)
    		)
    	}
    	is UiState.Success -> {
    		(user as UiState.Success).data?.let {
    			ProfileView(user = it)
    		}
    	}
    }
    
    when (posts) {
    	is UiState.Loading -> {
    		CircularProgressIndicator(
    			modifier = Modifier.wrapContentWidth(CenterHorizontally)
    		)
    	}
    	is UiState.Success -> {
    		(posts as UiState.Success).data?.let {
    			PostView(post = it)
    		}
    	}
    }
    How do i make sure that
    PostView()
    is drawn below
    ProfileView()
    ?
    z
    m
    • 3
    • 9
  • z

    Zun

    06/15/2021, 4:55 PM
    Is there an easy way to make my transparent topBar overlay the content in my Scaffold, or do I manually need to add my toolbar+content in a box?
    t
    • 2
    • 4
  • k

    Kaustubh Patange

    06/15/2021, 5:23 PM
    SaveableStateHolder does not restore 
    rememberSaveable
     values after process death when it is wrapped with a 
    CrossFade
     animation - https://issuetracker.google.com/issues/191059138 Can anyone verify this?
    t
    a
    • 3
    • 6
  • m

    ms

    06/15/2021, 5:39 PM
    What is the preferred approach • pass
    ViewModel
    as a param to the composable • use
    Koin
    to inject
    ViewModel
    Can you point out pros & cons also because I don't see much of a difference
    i
    d
    c
    • 4
    • 4
  • z

    Zach Klippenstein (he/him) [MOD]

    06/15/2021, 5:58 PM
    I just published a new blog post about
    derivedStateOf
    since I haven’t seen a lot of content about this particular function yet.
    ❤️ 1
    👀 3
    🎉 28
    h
    • 2
    • 2
Powered by Linen
Title
z

Zach Klippenstein (he/him) [MOD]

06/15/2021, 5:58 PM
I just published a new blog post about
derivedStateOf
since I haven’t seen a lot of content about this particular function yet.
❤️ 1
👀 3
🎉 28
h

Halil Ozercan

06/15/2021, 7:29 PM
Thanks for giving
derivedStateOf
a structure. I also used it in my schedule calendar example and loved it. I kinda though of it as a
remember
call that figures out its keys automatically 😄 ofc it's much more than that as you explained in detail.
z

Zach Klippenstein (he/him) [MOD]

06/15/2021, 7:48 PM
There are so many analogies that apply to it. Quite the little worker bee!
View count: 1