https://kotlinlang.org logo
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
  • a

    Ahmet Delibaş

    03/04/2021, 8:15 PM
    Hi guys. i have an issue. I need use mirror effect on my ExoPlayer PreviewView and here is my code:
    • 1
    • 1
  • m

    Marko Novakovic

    03/04/2021, 9:25 PM
    Am building
    Owl
    on my own to practice
    Compose
    . I have problem with
    BottomNavigation
    and navigation component. code in thread.
    o
    n
    • 3
    • 9
  • b

    Bradleycorn

    03/04/2021, 9:39 PM
    I'm learning about
    CompositionLocal
    and when/how to use it. Does this seem like a valid use case: Using a Material theme, the designer provided direction for Outlined Buttons ... When a button is displayed on the surface or background color, it should use the Theme's
    Secondary
    color. When a button is displayed on another color, it should use that color's "on" Color. To achieve this, I wrote an
    AppSurface
    Composable that wraps a regular surface, and sets the value of a
    LocalButtonColor
    composition local, and then wrote a
    AppOutlinedButton
    Composable that wraps a regular OutlinedButton, and sets it's color using the
    LocalButtonColor
    ... Does this seem like the right approach? (Code is posted in the thread)
    s
    • 2
    • 4
  • p

    Piotr Prus

    03/04/2021, 9:41 PM
    I do not know, if that is intended behaviour or bug, but detectGesture has change from alpha12 to beta01 for scrollable widgets. I have a BottomSheetScaffold, where bottomSheet is a
    Column(modifier.verticalScroll)
    , additionally I got a
    .pointeInput
    on it to detect when the dragGesture (scroll) actually happens. In alpha12, the dragGesture was detected on that column, but on Beta01, the
    detectVerticalDrag
    is never called. However , if the
    .pointerInput
    is called on child composable of that column, everything works fine. Is that a bug or intended behavior for scrollable columns? (Tested also for LazyColumns, which works exactly the same.
    • 1
    • 1
  • a

    Arkadii Ivanov

    03/04/2021, 9:48 PM
    Is there a way to center content inside 
    Box
     vertically, if the height of the 
    Box
     is smaller than the height of the content? Currently it sticks to the top and is clipped at the bottom. But I want the content to be centered and clipped from top and bottom.
    p
    • 2
    • 3
  • j

    julioromano

    03/04/2021, 10:30 PM
    Box {
      One()
      Two()
    }
    I have 2 composables inside a
    Box()
    . I’d like the Box to set its size to the size of
    One()
    and I’d also like that
    Two()
    adapts its size to the size of
    One()
    . Is this possible?
    p
    d
    +2
    • 5
    • 8
  • t

    Tristan

    03/04/2021, 10:36 PM
    Hello, I am having issues understanding how works arrangement in Jetpack Compose. I have 2 columns. I would the column on the right to take as much as needed, and the column on the left, to deal with the remaining space. In the remaining space, an image should be trying to take as much space as possible without compromising its aspect ratio. But I don’t find how to do it. Each time, the left column has more importance. This is the code I use at the moment,
    Untitled
    • 1
    • 2
  • s

    Sergey Y.

    03/04/2021, 11:36 PM
    How do I enable the new `experimental multithreaded recomposition`(yes, I am aware of the problems)? Leland said on the stream that it is now possible and you can turn it on and play. I'm reading the source for the
    CompositionContext
    class, but I don't know how to use it. Can anyone please help? Thanks 🙂
    d
    a
    k
    • 4
    • 11
  • s

    sen kumar

    03/05/2021, 1:18 AM
    In AnimatedVisibility the parent view get pushed upwards when I make them visible - How do I make the child view push downwards ?
    d
    d
    • 3
    • 16
  • c

    Colton Idle

    03/05/2021, 2:13 AM
    Fun question to stir up the channel... At what point do we just use stackoverflow to make sure all of these great answers from the Android dev team (and others) are actually searchable? With compose beta, the api is now "stable" so should we start moving more questions there (and maybe post the questions here if they don't get traction?)
    👍 1
    a
    j
    c
    • 4
    • 6
  • t

    tad

    03/05/2021, 2:38 AM
    Should
    paddingFromBaseline(top = fontSize, bottom = lineHeight - fontSize)
    be the default for Text? It's tough to match Figma/Sketch mocks without something that wraps Text to provide that modifier.
    • 1
    • 1
  • v

    Vinay Gaba

    03/05/2021, 3:30 AM
    I’m curious about whether there is an API that allows me to get a callback about a composable being rendered on the screen or potentially modify a composable function right before its rendered. Sounds crazy I know but an API like
    LayoutInflater.Factory2
    gave some of this functionality in classic Android. Just curious if something like this already exists or is planned for in Compose.
    a
    z
    • 3
    • 23
  • j

    Jason Inbody

    03/05/2021, 4:32 AM
    Did the Stack view get deprecated? Android studio isn't finding the import. I'm using compose beta01 btw. Edit: Oh looks like Box is now Stack
    a
    • 2
    • 3
  • l

    Landerl Young

    03/05/2021, 9:22 AM
    Does compose currently provide something like a AutoResizeText? If not how do implement one following the best practice? I currently came across same feature need, and what I did is like this:
    var baseSize by remember { mutableStateOf(0f) }    
    Column(
            modifier = modifier.onSizeChanged { (width, height) ->
                baseSize = min(width * 1.7f, height.toFloat())
            }
    ) {
            val firstLevelSize = baseSize * 5 / 10
            Text(
                fontSize = LocalDensity.current.run {
                    firstLevelSize.toSp()
                },
               ...
            )
        }
    Full code here: https://github.com/LanderlYoung/FlashAppSearch/blob/16a1fc9ac6c67e184f801e125f79ef[…]o/github/landerlyoung/flashappsearch/search/ui/piece/KeyIcon.kt But this code has a issue: during the initial composition the fontSize is 0, so the Text is not shown. when onSizeChanged got called, baseSize would update, and causing a second pass re-composition, at that time the Text is actually shown. Is there any better solutions? BTW, there is a StackOverFlow thread // https://stackoverflow.com/questions/63971569/androidautosizetexttype-in-jetpack-compose
    a
    • 2
    • 2
  • s

    Syex

    03/05/2021, 9:31 AM
    Hello, I have a
    TextField
    and a
    Button
    . Upon a click on the button I want to clear the focus from the
    TextField
    so the keyboard disappears. I'm currently trying
    Button(
        onClick = {
            FocusRequester.Default.freeFocus()
        }
    )
    This crashes the app with
    java.lang.IllegalStateException: FocusRequester is not initialized. One reason for this is that you requesting focus changes during composition. Focus requesters should not be made during composition, but should be made in response to some event.
    Is there any other way to achieve this?
    c
    l
    • 3
    • 7
  • s

    Simone Summo

    03/05/2021, 9:50 AM
    Hello, I am following this to implement navigation with bottomBar, now I want to open a child from a list that need to show full screen, I call it a modal, how can I achieve this behaviour? At the moment, using nested navigation, it opens inside the content space, with the bottom bar visible.
    i
    t
    • 3
    • 2
  • e

    escodro

    03/05/2021, 12:18 PM
    Hello! 👋 I have a question regarding delegating Composables to inner nodes. Could someone help me? I have a
    ModalBottomSheetLayout
    that I want to appear on top of my
    Scaffold
    . The
    Scaffold
    has 4 tabs and I want each one to have a different content for this Modal. The solution I made is:
    val (sheetContent, setSheetContent) = remember { mutableStateOf<@Composable () -> Unit>({}) }
    AlkaaBottomSheetLayout(bottomSheetContent = currentSection) {
        Scaffold {
            when (tab) {
                HomeSection.Tasks -> TaskListSection(bottomSheetContent = setCurrentSection)
                HomeSection.Search -> SearchSection(bottomSheetContent = setCurrentSection)
                HomeSection.Categories -> CategoriesSection(bottomSheetContent = setCurrentSection)
                HomeSection.Settings -> SettingSection(bottomSheetContent = setCurrentSection)
    Is it the correct way to delegate the composable function? Thanks a lot in advance! ❤️
    j
    • 2
    • 5
  • f

    FunkyMuse

    03/05/2021, 12:22 PM
    @OptIn(ExperimentalComposeUiApi::class)
    @Composable
    fun SearchInput(onInputText: (inputText: String) -> Unit = {}) {
        val keyboardController = LocalSoftwareKeyboardController.current
        var inputText by rememberSaveable { mutableStateOf("") }
        val invalidInput = inputText.isBlank()
    
        OutlinedTextField(
            modifier = Modifier
                .fillMaxWidth()
                .padding(start = 24.dp, end = 24.dp),
            isError = invalidInput,
            label = { Text(text = stringResource(id = R.string.search)) },
            value = inputText,
            onValueChange = { inputText = it },
            keyboardOptions = KeyboardOptions(
                KeyboardCapitalization.Words, autoCorrect = false,
                keyboardType = KeyboardType.Text, imeAction = ImeAction.Search
            ),
            keyboardActions = KeyboardActions(onSearch = {
                keyboardController?.hideSoftwareKeyboard()
                onInputText(inputText)
            })
        )
    }
    Hey guys, the code above crashes when the app goes into onPause/onStop the error is
    java.lang.RuntimeException: Parcel: unable to marshal value androidx.compose.runtime.SnapshotMutableStateImpl@f5abce7
    at android.os.Parcel.writeValue(Parcel.java:1926)
    at android.os.Parcel.writeList(Parcel.java:1133)
    at android.os.Parcel.writeValue(Parcel.java:1873)
    at android.os.Parcel.writeMapInternal(Parcel.java:984)
    at android.os.Parcel.writeMap(Parcel.java:966)
    at android.os.Parcel.writeValue(Parcel.java:1838)
    at android.os.Parcel.writeMapInternal(Parcel.java:984)
    at android.os.Parcel.writeMap(Parcel.java:966)
    at android.os.Parcel.writeValue(Parcel.java:1838)
    at android.os.Parcel.writeList(Parcel.java:1133)
    at android.os.Parcel.writeValue(Parcel.java:1873)
    at android.os.Parcel.writeArrayMapInternal(Parcel.java:1016)
    at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1620)
    at android.os.Bundle.writeToParcel(Bundle.java:1303)
    at android.os.Parcel.writeBundle(Parcel.java:1085)
    at android.os.Parcel.writeValue(Parcel.java:1842)
    at android.os.Parcel.writeArrayMapInternal(Parcel.java:1016)
    at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1620)
    at android.os.Bundle.writeToParcel(Bundle.java:1303)
    at android.os.Parcel.writeBundle(Parcel.java:1085)
    at android.os.Parcel.writeValue(Parcel.java:1842)
    at android.os.BaseBundle.dumpStats(BaseBundle.java:1690)
    at android.os.BaseBundle.dumpStats(BaseBundle.java:1727)
    at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:150)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7729)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:974)
    if i use
    var inputText by remember { mutableStateOf("") }
    the issue goes away i've made the code by the Unidirectional data flow in Jetpack Compose documentation
    :thread-please: 2
    a
    • 2
    • 2
  • p

    Pedro Gomez

    03/05/2021, 12:37 PM
    Hi all! Congrats for the first beta release 👏 I'm just wondering if we know when the beta02 release is going to be published. There is an ArrayOutOfBoundsException already reported on the issue tracker and fixed that I'm waiting for. Thanks!
    s
    • 2
    • 2
  • d

    Dominaezzz

    03/05/2021, 12:45 PM
    I'm using
    Modifier.selectable(...)
    and when the composable is clicked, the animation plays and UI is updated, but the composable doesn't stay selected (graphically speaking). Do I have to change the background colour myself?
    m
    • 2
    • 7
  • l

    Lilly

    03/05/2021, 1:10 PM
    Hi, what back button behavior would you guys expect with bottom navigation. Would you retain the history or always pop to the root tab? If we have for instance 3 tabs, would you expect A -> B -> C -> A -> B ; pressing back button: A -> C -> B -> A or would you expect A. Material Design doesn't cover this clearly and I read that google apps arent consistent here
    g
    j
    +3
    • 6
    • 8
  • j

    Jorkoh

    03/05/2021, 1:14 PM
    This is a dumb one but how can I force the second element of a Row to have a minimum height equal to the height of the first element of that Row?
    v
    • 2
    • 2
  • m

    myanmarking

    03/05/2021, 3:24 PM
    what’s the replacement for Modifier.weight in latest version ?
    s
    • 2
    • 8
  • l

    Lukas K-G

    03/05/2021, 3:27 PM
    How would I capture DPad input in a composable function? 🤔
    • 1
    • 1
  • r

    Rajashekar

    03/05/2021, 3:40 PM
    Does TextField allows us to specify max length of characters to enter? All I can see is it takes maxLines and singleLine. There is no support yet?
    f
    • 2
    • 4
  • m

    myanmarking

    03/05/2021, 3:53 PM
    @Composable
    private fun PeopleScreen() {
        val viewModel: PeopleViewModel2 = viewModel()
    
        val viewState = viewModel.peopleList.collectAsState(initial = emptyList())
        val listItems: List<PeopleItem> by viewState
    
        LazyColumn(
            contentPadding = PaddingValues(horizontal = 8.dp, vertical = 16.dp),
            modifier = Modifier.padding(bottom = 56.dp)
                .fillMaxWidth()
        ) {
            for (item in listItem) {
                item(key = item.id) {
                    PeopleItem(
                        item = item,
                        onFavouriteClicked = { viewModel.onFavouriteClicked(item) }
                    )
                    Spacer(modifier = Modifier.padding(bottom = 8.dp))
                }
            }
        }
    }
    t
    • 2
    • 2
  • z

    zoha131

    03/05/2021, 4:10 PM
    i am struggling to use hilt with navigation-compose library. can anyone suggest any documentation or sample? actually i didn't found any documentation.
    z
    i
    • 3
    • 9
  • a

    alorma

    03/05/2021, 4:54 PM
    How can i make a
    IconButton
    with elevation shadow?
    j
    l
    • 3
    • 3
  • a

    alorma

    03/05/2021, 5:10 PM
    Another: Is there a way to check if a
    Provider
    is... provided? Ex: WindowInsets from accompanist, in a library, check if is provided by the main app and apply the
    Modifier.statusBarPadding()
    or else do nothing in the lib
    c
    • 2
    • 2
  • f

    Filip Wiesner

    03/05/2021, 5:56 PM
    Hello, I've been trying to implement paging with Paging 3 (both source and mediator) and Lazy column. Whenever I "scroll too fast" the app crashes with
    IllegalArgumentException: Failed requirement
    . The stacktrace points to
    MeasureAndLayoutDelegate.kt:194
    which is
    require(!duringMeasureLayout)
    . So my question is if I should look for some problem on my side or if it's likely a bug and I should create minimial repro and file an issue. Thanks for reply 🙏
    d
    a
    • 3
    • 4
Powered by Linen
Title
f

Filip Wiesner

03/05/2021, 5:56 PM
Hello, I've been trying to implement paging with Paging 3 (both source and mediator) and Lazy column. Whenever I "scroll too fast" the app crashes with
IllegalArgumentException: Failed requirement
. The stacktrace points to
MeasureAndLayoutDelegate.kt:194
which is
require(!duringMeasureLayout)
. So my question is if I should look for some problem on my side or if it's likely a bug and I should create minimial repro and file an issue. Thanks for reply 🙏
d

Dominaezzz

03/05/2021, 6:16 PM
It oddly looks like a race condition. I'd say minimal repro.
a

Andrey Kulikov

03/05/2021, 6:31 PM
Yes, please file a bug with a repro, it will help to find a fix
f

Filip Wiesner

03/05/2021, 8:58 PM
Ok, I'll see what I can do. Thanks 👌
Reported ✅ https://issuetracker.google.com/issues/182029524
View count: 2