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

    prat

    12/28/2020, 4:24 PM
    Hi, I'm learning how effect works and trying to understand why
    millis
    value doesn't change when I add a log at A - before Canvas. Without the log or when I add log at B instead,
    millis
    gets updated. Is this an expected behavior?
    @Composable
    fun DrawSomething(
        modifier: Modifier,
        strokeWidth: Float = 8f
    ) {
        val millis = animationTimeMillis()
    
    // A: when adding a Log here, millis.value will stop at 0 and won't draw arc
    // Log.d("DrawSomething", "millis : ${millis.value}")
    
        Canvas(modifier = modifier) {
    
            // B
            // Log.d("DrawSomething", "millis : ${millis.value}")
    
            drawArc(
                color = Color.Green,
                startAngle = 0f,
                sweepAngle = 0f + (millis.value / 360),
                useCenter = false,
                size = Size(100f, 100f),
                style = Stroke(width = strokeWidth)
            )
        }
    }
    @Composable
    fun animationTimeMillis(): State<Long> {
        val millisState = mutableStateOf(0L)
        val lifecycleOwner = AmbientLifecycleOwner.current
        LaunchedEffect(Unit) {
            val startTime = withFrameMillis { it }
            lifecycleOwner.whenStarted {
                while (true) {
                    withFrameMillis { frameTime ->
                        millisState.value = frameTime - startTime
                    }
                }
            }
        }
        return millisState
    }
    a
    12 replies · 2 participants
  • r

    robnik

    12/28/2020, 8:31 PM
    I'd like to use BottomNavigation where each tab remembers its navigation state. Is this supported with Compose Navigation?
    👀 2
    k
    i
    +1
    3 replies · 4 participants
  • b

    Brady Aiello

    12/29/2020, 2:52 AM
    Anyone ever have this issue with bouncing text in a
    TextField
    ? I can resolve it with
    singleLine = true
    , but it still chops off the bottom of the sub-baseline letters. This is in a
    TopAppBar
    in a Scaffold. Thought this might be due to a size constraint on
    TopAppBar
    ? Or maybe just the
    topAppBar
    content parameter in
    Scaffold
    ? Not sure if there's any weird trickiness with
    TextField
    itself.
    s
    3 replies · 2 participants
  • m

    Marcin Środa

    12/29/2020, 8:24 AM
    Has anyone worked on a camera or photo gallery? Looking for photo capture / image selector.
    t
    2 replies · 2 participants
  • l

    lewis

    12/29/2020, 10:05 AM
    How can I get
    BottomAppBar
    to hide when I scroll down in my
    ScrollableColumn
    ?
    c
    1 reply · 2 participants
  • t

    tseisel

    12/29/2020, 5:46 PM
    Today I tried Jetpack Compose. While it looks promising, has anyone noticed how long it is to update a composable
    @Preview
    ? It takes almost a minute to render each change, and I'm using a decent laptop. Also, is it required to rebuild project to update preview ?
    z
    n
    +4
    7 replies · 7 participants
  • l

    Lilly

    12/30/2020, 2:08 AM
    Is someone aware of a sample app where data is not only retrieved but also send to repository? I'm wondering how to collect all the state in different composable when event is triggered. First thought is to hoist all the state to
    ViewModel
    ...
    b
    s
    +1
    10 replies · 4 participants
  • n

    Nana Vong

    12/30/2020, 6:04 AM
    When Scaffold bodyContent includes LazyColumn ,sliding becomes very jerky !😫
    😭 4
    s
    z
    +1
    3 replies · 4 participants
  • s

    Se7eN

    12/30/2020, 1:49 PM
    I have this code and I'm getting this weird bug you can see in the video. The bug goes away when I remove the three `Text`s for R, G and B values. Here is the code:
    val colors = remember {
        mutableStateListOf(
            mutableStateListOf(Color.Magenta, Color.Blue, Color.Yellow)
        )
    }
    val activeRowIndex = remember { mutableStateOf(0) }
    val activeColumnIndex = remember { mutableStateOf(0) }
    
    ...
    
    Sliders(
        colors[activeRowIndex.value][activeColumnIndex.value],
        onColorChange = { colors[activeRowIndex.value][activeColumnIndex.value] = it }
    )
    @Composable
    fun Sliders(color: Color, onColorChange: (Color) -> Unit) {
        Column {
            Row(verticalAlignment = Alignment.CenterVertically) {
                Text(text = "R - ${color.red * 255}")
                Slider(
                    value = color.red,
                    onValueChange = { onColorChange(color.copy(red = it)) }
                )
            }
            Row(verticalAlignment = Alignment.CenterVertically) {
                Text(text = "G - ${color.green * 255}")
                Slider(
                    value = color.green,
                    onValueChange = { onColorChange(color.copy(green = it)) }
                )
            }
            Row(verticalAlignment = Alignment.CenterVertically) {
                Text(text = "B - ${color.blue * 255}")
                Slider(
                    value = color.blue,
                    onValueChange = { onColorChange(color.copy(blue = it)) }
                )
            }
        }
    }
    SlidersBug.mp4
    t
    t
    4 replies · 3 participants
  • c

    Colton Idle

    12/30/2020, 6:58 PM
    https://jakewharton.com/a-jetpack-compose-by-any-other-name/ Anyone else here think there should be some sort of name change? 👍 or 👎 Personally, I've talked to people about Jetpack Compose and they find "Jetpack" to be weird. I think I'm only "okay" with it because I've grown used to "jetpack" as a term that we use when talking about android dev. "Jetbrains Compose" for desktop could also be confusing. I think just having Compose (and saying that its available for Android and desktop) is easiest when talking about the UI, and the compiler and runtime could probably just be renamed. Seems like that would be the least amount of friction.
    👎 3
    👍 47
    r
    a
    +2
    16 replies · 5 participants
  • s

    Sam

    12/30/2020, 8:10 PM
    Hi, we are on the verge of releasing our Android app that is built entirely in Compose 🥳🥳🥳 problem is we have a major blocker:
    BasicTextField
    often doesn’t bring up the keyboard when focused! When it malfunctions, the cursor is literally blinking, yet somehow the keyboard is not open. This happens on physical Pixel 4a in a release build that is deployed to the play store! Since we are chat-based communities, this is critical. How is it even possible to get into this state, and are there any workarounds/hacks that can fix this reliability bug?
    👍 2
    😭 3
    r
    c
    +4
    36 replies · 7 participants
  • d

    Denis

    12/30/2020, 10:47 PM
    I need to detect touch events and change some state with respect to up and down motion events. The next code (see the thread) works well with simple taps, but if I tap with 3 fingers, it adds only "Down" event, but no "Up". What could be the problem? Do I need to use something else besides
    pointerInteropFilter
    ?
    ✅ 1
    2 replies · 1 participant
  • q

    Qracle

    12/31/2020, 1:52 AM
    Hi, new to Compose and played around with the Compose codelab samples regarding theming, but having issues with previewing light & dark themes. Greatly appreciate any help / advice!
    Untitled
    3 replies · 1 participant
  • b

    birdsofparadise

    12/31/2020, 2:14 AM
    The Compose's NavigationController doesn't allow for "free-form" navigation. I get that having a laid out static navigation graph is great, but in a considerably large project I don't think its tenable. I was able to create a "hacky" solution. However I'm curious why "free-form" navigation isn't directly supported? Answer: A static graph must to be created at start up to handle resuming after process death Hopefully something better will come along soon!
    👍 1
    a
    i
    +2
    84 replies · 5 participants
  • p

    Piotr

    12/31/2020, 10:01 AM
    Hi,  Quick question, is there some quick way to achieve foldable text section like I have on screen? Everything works correctly I just need to have the more after the … so it looks something like this
    k
    1 reply · 2 participants
  • d

    Dominaezzz

    12/31/2020, 2:54 PM
    Are there plans for more spans for
    AnnotatedString
    ? Like
    BulletSpan
    ,
    QuoteSpan
    , etc. (Unless this can be achieved already?)
    h
    z
    4 replies · 3 participants
  • c

    Christian Maier

    12/31/2020, 4:20 PM
    Let’s say I’d like to animate a Card() using a FloatPropKey with values from 0f to 1f. How could I approach this currently?
    d
    9 replies · 2 participants
  • v

    Vsevolod Ganin

    12/31/2020, 7:41 PM
    How to combine different gesture detectors using
    pointerInput
    ? My goal is combine zooming (1), scrolling (2) and drag-n-drop (3) on the same composable. 1 and 2 are available with
    detectMultitouchGestures
    . 3 could be done using
    detectTapGestures
    +
    detectDragGestures
    I guess. The idea is to listen to gesture trigger first and then give full control to corresponding gesture routine. Honestly I don’t how to approach this, the examples don’t cover this it seems
    r
    3 replies · 2 participants
  • m

    Michael Prenez-Isbell

    01/01/2021, 1:22 PM
    Hey, SwiftUI developer, taking the Ray Wenderlich Jetpack Compose course.
    r
    c
    2 replies · 3 participants
  • a

    Ayomide

    01/01/2021, 4:21 PM
    Hi, is this documentation up to date? I can't seem to pass a string to the
    navController.navigate()
    method
    g
    i
    +1
    3 replies · 4 participants
  • a

    ahulyk

    01/01/2021, 7:08 PM
    How to add animation in the end of the list when using:
    LazyColumn
    ?
    d
    4 replies · 2 participants
  • a

    ahulyk

    01/01/2021, 9:09 PM
    Right now there is no possibility to use Transitions when using Jetpack Navigation?
    i
    1 reply · 2 participants
  • b

    Bradleycorn

    01/01/2021, 11:47 PM
    hrm ... with Navigation, is this the proper way to deal with an argument that is an Enum value? I have a sealed class with my routes:
    sealed class Screen(val route: String, val title: String, val isTopLevel: Boolean = false) {
    
        object Category: Screen("category/{postType}", "Category") {
            // here I define a NavType.EnumType for my enum that is used for an argument.
            val postTypeArgType = NavType.EnumType(PostType::class.java)
            
            fun buildRoute(postType: PostType): String {
                return "category/${postType.name}"
            }
        }
    
        // ... more screen routes defined here..
    }
    Then I use the Category to build the composable() in the NavGraph Builder. And I use the
    postTypeArgType
    which is a
    NavType.EnumType
    from the Category object above to get the postType argument. Is this the right approach?
    composable(Screen.Category.route,
            arguments = listOf(
                navArgument("postType") { type = Screen.Category.postTypeArgType },                            
                navArgument("title") { type = NavType.StringType }
            )
        ) { backStackEntry ->
            val vm: CategoryScreenViewModel = navViewModel()
    
            // Is this the right way to get the `postType` argument from the backstack entry?
            val postType = Screen.Category.postTypeArgType.get(backStackEntry.arguments?: Bundle(), "postType") ?: PostType.OTHER
    
            CategoryScreen(vm, postType)
        }
    i
    1 reply · 2 participants
  • b

    birdsofparadise

    01/02/2021, 12:56 AM
    Are you not able to use
    remember
    with an inlined Compose function?
    @Composable
    inline fun test() {
        val i by remember { mutableStateOf(3) }
    }
    This method produces a nasty compiler error Part of the error message:
    Caused by: java.lang.RuntimeException: Exception while generating code for:
    FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit [inline]
      annotations:
        Composable
      BLOCK_BODY
        VAR name:$i$f$test type:<http://kotlin.Int|kotlin.Int> [val]
          CONST Int type=<http://kotlin.Int|kotlin.Int> value=0
        VAR name:i type:<http://kotlin.Int|kotlin.Int> [val]
          CALL 'public final fun remember <T> (calculation: @[ComposableContract(restartable = <null>, readonly = <null>, tracked = <null>, preventCapture = 'true')] kotlin.Function0<T of androidx.compose.runtime.RememberKt.remember>): T of androidx.compose.runtime.RememberKt.remember [inline] declared in androidx.compose.runtime.RememberKt' type=<http://kotlin.Int|kotlin.Int> origin=null
            <T>: <http://kotlin.Int|kotlin.Int>
            calculation: BLOCK type=kotlin.Function0<kotlin.Int> origin=LAMBDA
              COMPOSITE type=kotlin.Unit origin=null
              FUNCTION_REFERENCE 'private final fun test$lambda-0 (): <http://kotlin.Int|kotlin.Int> declared in dev.birdsofparadise.mua.lifecycle.ComposeActivityKt' type=kotlin.Function0<kotlin.Int> origin=LAMBDA reflectionTarget=null
    v
    s
    12 replies · 3 participants
  • m

    Marcello Galhardo

    01/02/2021, 9:46 AM
    Hey! I'm starting to play with compose and I have a question around
    SavedStateRegistry
    . I notice I have an
    Ambient
    for
    UiSavedStateRegistry
    but there's no for
    SavedStateRegistry
    . - and look like they are totally different types so I can't create a custom
    AbstractSavedStateViewModelProviderFactory
    without a
    SavedStateRegistryOwner
    . What is the correct way to get a
    SavedStateRegistryOwner
    in a composable? 🤔
    i
    3 replies · 2 participants
  • s

    Shakil Karim

    01/02/2021, 12:10 PM
    How can I disable the ripple effect when using card in Compose?
    n
    1 reply · 2 participants
  • c

    Christian Maier

    01/02/2021, 2:17 PM
    When I shrink a Card using a tween animation, how can change the size another card as soon as the tween animation is finished? Traditionally, I’d think of an end-Listener and start an animation on another View
    j
    13 replies · 2 participants
  • r

    rsktash

    01/02/2021, 4:44 PM
    Hi. Is there a way to render out of parent bounds I need to transform topappbar to searchscreen
    Screen_Recording_20210102-214025_Gmail.mp4
    d
    1 reply · 2 participants
  • k

    Karthick

    01/03/2021, 3:30 AM
    Is the title not centred is normal.
    f
    r
    +2
    13 replies · 5 participants
  • p

    Prashant Priyadarshi

    01/03/2021, 3:49 AM
    Problem : Bottom app bar in scaffold jumping up above keyboard even when its not required I have two text fields in below screen, when text input starts in the top filter screen, then bottom app bar which also have a input field, jumps with the keyboard, this hides part of the list in background and is undesirable. Any idea how to prevent it.
    c
    z
    9 replies · 3 participants
Powered by Linen
Title
p

Prashant Priyadarshi

01/03/2021, 3:49 AM
Problem : Bottom app bar in scaffold jumping up above keyboard even when its not required I have two text fields in below screen, when text input starts in the top filter screen, then bottom app bar which also have a input field, jumps with the keyboard, this hides part of the list in background and is undesirable. Any idea how to prevent it.
c

Colton Idle

01/03/2021, 4:28 AM
not sure if its the same issue, but @Sam recently had some edit text issues with the keyboard I think. maybe you can find that thread above that he started.
p

Prashant Priyadarshi

01/03/2021, 5:31 AM
@Colton Idle about the keyboard not coming up? I am also getting that bug randomly. did the focusRequester fix..
@Colton Idle how ever for my case I tried to release focus from the input field in bottom app bar when text input starts in upper text field, but it doesn't work..
z

zoha131

01/03/2021, 6:36 AM
Can you share a sample code?
p

Prashant Priyadarshi

01/03/2021, 7:55 AM
@zoha131 https://kotlinlang.slack.com/archives/CJLTWPH7S/p1609359851394100
z

zoha131

01/03/2021, 4:07 PM
@Prashant Priyadarshi actually I was asking for your version where the bottomnav goes up undesirably.
p

Prashant Priyadarshi

01/04/2021, 3:26 AM
Hi @zoha131, This occurs when I use android:windowSoftInputMode="adjustResize" in my android manifest file,
<activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:windowSoftInputMode="adjustResize"
            android:theme="@style/Theme.LearnCompose.NoActionBar">
below is the sample code and I have also attached the screen shot
@Composable
    fun scaffoldWithTwoInputs(){
        val topText = remember { mutableStateOf("") }
        val bottomText = remember { mutableStateOf("") }
        val modifier = Modifier.fillMaxWidth()
    Scaffold(modifier = Modifier.fillMaxSize(),
            topBar = {
                OutlinedTextField(value = topText.value,
                        onValueChange = {s-> topText.value = s }, modifier = modifier)
            },
            bodyContent = {
                Column(modifier = modifier.padding(50.dp), verticalArrangement = Arrangement.Center) {
                    Text(text = topText.value, style = typography.h6, color = Color.Black)
                    Text(text = bottomText.value, style = typography.h6, color = Color.Black)
                }
            },
            bottomBar = {
                OutlinedTextField(value = bottomText.value, onValueChange = {s-> bottomText.value = s },
                        modifier = modifier)
            }
    )
}
@zoha131 I used adjustResize because without using it, softkeyboard covers parts of input text field of bottomAppBar as in below pic Any suggestions ...
z

zoha131

01/04/2021, 8:05 AM
I am not clear with your use-case. You want to hide the inputfield of the bottom when it is not in focus? You are using InputField inside the
bottomBar
. But from you first message I thought You want to hide the bottom nav when keyboard is visible in the screen. Can you please clear what do want to achieve? You can use this library to detect if keyboard is visible or not.
View count: 3