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

    zoha131

    01/22/2021, 4:38 PM
    Finally I have completed my Final Year Project using Jetpack Compose UI only.🥳 Thank you so much for helping me throughout the projects.
    SmartCR.mp4
    👏 10
    ❤️ 7
    r
    • 2
    • 1
  • k

    Kshitij Patil

    01/22/2021, 4:56 PM
    does the
    7094152
    snapshot of accompanist have been released properly or still there are some files to be uploaded? I’m getting read timeout for metadata.xml
    c
    • 2
    • 5
  • s

    Shakil Karim

    01/22/2021, 6:32 PM
    How can I achieve snapping like behavior in LazyRow? is there any built-in method to do that?
    ➕ 3
    v
    d
    • 3
    • 4
  • c

    chris-horner

    01/23/2021, 1:25 AM
    Does anyone have any recommendations around presenting a Snackbar once? Driving the UI from state is easy except when I want to present something at a particular point in time, and only once. I could create state that contains something like
    showSnackbar
    , but if my UI gets recomposed because of a configuration change the Snackbar will show again. Is the recommended approach to handle the timing in whatever produces state, and after a period of time output state with
    showSnackbar = false
    ?
    a
    j
    • 3
    • 6
  • c

    Colton Idle

    01/23/2021, 5:53 AM
    Can we add a "content description" to an image in compose?
    c
    a
    • 3
    • 7
  • h

    Hitanshu Dhawan

    01/23/2021, 6:15 AM
    Hey everyone, What is the correct way of dealing with state and ComposeNavigation? I’m facing an issue where the same code works fine for simple composable but doesn’t work when wrapped inside of a NavHost. Code snippets and details in the thread…
    j
    • 2
    • 5
  • k

    Kshitij Patil

    01/23/2021, 7:46 AM
    I’m using compose snapshot
    7094152
    and found that
    LaunchedEffect
    no longer accepts subject which used to re-launch the
    block()
    on value changes. What is the alternative then?
    s
    • 2
    • 3
  • k

    Kshitij Patil

    01/23/2021, 8:18 AM
    When I try to make TextField pre-focused using
    onActive { focusRequester.requestFocus() }
    keyboard doesn’t open, when focused manually, it works fine, what could be the issue? is there any other way of doing the same? also, I noticed
    onActive { }
    callback is getting deprecated. What should we use instead?
    k
    j
    r
    • 4
    • 15
  • k

    Kshitij Patil

    01/23/2021, 1:00 PM
    I’m getting
    ClassCastException
    for String to AnnotatedString when passing in String to
    TextFieldValue
    in Compose snapshot
    7094152
    Stacktrace ⤵️
    j
    s
    • 3
    • 10
  • t

    Tuba Kesten

    01/23/2021, 4:45 PM
    @Composable
    Outer() {
      profileResult = viewmodel.field.observeAsState()
      Inner(profileResult)
    }
    @Composable
    Inner(myProfileResult: ProfileResult){
        NavHost(
           navController = editProfileNavController,
           startDestination = EditProfileScreen.EditProfile
        ) {
           Timber.d("profileResult1 ${myProfileResult.workEducationItems}")
           composable(EditProfileScreen.EditProfile) {
                Timber.d("profileResult2 ${myProfileResult.workEducationItems}")
                ScrollableColumn(
                     modifier.padding(top= 100.dp).fillMaxSize(),
                     horizontalAlignment = Alignment.CenterHorizontally
                ) { ....
    }
    Hi guys, I have a question related to recomposition of NavHost Composable. When the data is refreshed, 
    profileResult1
      holds the new data but 
    profileResult2
      still hold the old data (even it is recomposed). Anybody has any idea why this is happening 😄 Any solution for that other than passing with Ambient 😄 Thanks!
    a
    • 2
    • 6
  • j

    judrummer

    01/23/2021, 7:35 PM
    Hi. I try to put some CustomView that extended EditText. It’s work fine except backspace doesn’t delete current text. Anyone found this problem before? This is simple Example Code
    @Composable
    fun TestScreen() {
        val context = AmbientContext.current
    
        val nativeView = remember {
            EditText(context)
                .apply {
                    layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
               
                    addTextChangedListener {
    
                    }
                }
        }
    
        Column(modifier = Modifier.fillMaxWidth()) {
            Text(text = "Some Label")
            AndroidView(viewBlock = { nativeView })
            Text(text = "Some Text")
        }
    }
    I can reproduce in this case Pixel2XL Android11 -> Keyboard ManMan But in below list.  It’s work fine Pixel2XL Android11  -> GKeyboard Oneplus7t Pro Android10  -> Keyboard ManMan Oneplus7t Pro Android10  -> GKeyboard
    s
    j
    • 3
    • 5
  • m

    Mehdi Haghgoo

    01/23/2021, 7:41 PM
    launchInComposition is gone? Why?
    t
    a
    • 3
    • 10
  • j

    jim

    01/23/2021, 7:46 PM
    I'm always a little surprised when I see people using
    AndroidView
    directly in their apps, and maybe it's because we made the API too pleasant to use or maybe it's because we never really communicated the intent to the community. 🤷. Certainly I never expected to see people remembering the view and then just referencing that view in the
    viewBlock
    , I suppose no API survives first encounter with the user. Composables are epitomized by their convenient declarative APIs. The older android Views often have imperative APIs with sometimes surprising semantics that need to be papered over, and this wallpaper isn't always straight forward to get right. The intent/expectation was that users would write a composable function who's sole purpose was to wrap a particular Android View, and would provide this wallpaper, such that the widget was pleasant to use in the rest of their application. Maybe we need to make AndroidView have some more boilerplate and look uglier 😛 😉🤣
    ☝️ 3
    😃 8
    🤣 5
    ➕ 1
    j
    t
    +6
    • 9
    • 23
  • c

    Colton Idle

    01/23/2021, 9:48 PM
    Testing question (learning about testing composables) This may be a silly question but I have a really simple composable. It's just two
    Text
    s. (you could even argue that this shouldn't be a separate compasable) Either way it's legitimately being used in my app and now I've been watching @ppvi (it says Jose if offline, so hopefully that doesn't ping him. Wasn't my intention.) compose testing talk and I want to write a test, but I've never really tested individual views before (not an android and not in any language) and now I'm not sure what to really assert. Maybe since it's such a contrived example there's not much to test and so it's actually a bad candidate, but should I just test that my composable is there with the text that I passed in the parameter? Any guidance would be appreciated.
    ❤️ 1
    j
    a
    f
    • 4
    • 28
  • s

    Shakil Karim

    01/23/2021, 10:05 PM
    Does using ViewPager as an AndroidView in Compose only app is a good approach for now? Or it can be easily done in Compose?
    a
    • 2
    • 3
  • c

    Colton Idle

    01/24/2021, 2:28 AM
    I find myself doing a lot of nested Columns inside of Rows and vice versa kinda like LinearLayout horizontal and vertical in Android view land. Having a deep enough heirarchy was viewed as a possible perf issue and so something like constraint layout was helpful. In compose, do I have to worry about having really nested Cols and Rows?
    j
    a
    a
    • 4
    • 11
  • c

    Colton Idle

    01/24/2021, 4:19 AM
    I feel like I know the answer to this question... but I'm going to ask it anyway. Iterating on a Composable and viewing the Preview in a new project is much faster (still not blazing fast) but definitely faster than a large existing project that I already have where we just added compose. Is it possible to just have an @Preview not have to rebuild the full project if the full project is needed? I realize it's probably easier said than done, but something like this
    @Preview(showBackground = true)
    @Composable
    fun Beep(){
        Text("Boop")
    }
    is just interesting that it takes like 5 minutes in my old project (because my existing project is super large it just builds slow overall) vs in a brand new project. What am I actually after? I want to be able to create and iterate on composables quickly and I feel like it might just be easier to create composable in compose-desktop and then just copy pasta back into my actual app.
    r
    m
    • 3
    • 2
  • m

    magnumrocha

    01/24/2021, 11:29 AM
    does anyone have a problem importing the dependency
    androidx.ui:ui-tooling:1.0.0-alpha10
    ?
    Execution failed for task ':samples:android:mergeDebugResources'.
    > Could not resolve all files for configuration ':samples:android:debugRuntimeClasspath'.
       > Could not find androidx.ui:ui-tooling:1.0.0-alpha10.
         Searched in the following locations:
           - <https://kotlin.bintray.com/kotlinx/androidx/ui/ui-tooling/1.0.0-alpha10/ui-tooling-1.0.0-alpha10.pom>
           - <https://dl.google.com/dl/android/maven2/androidx/ui/ui-tooling/1.0.0-alpha10/ui-tooling-1.0.0-alpha10.pom>
           - <https://jcenter.bintray.com/androidx/ui/ui-tooling/1.0.0-alpha10/ui-tooling-1.0.0-alpha10.pom>
         Required by:
             project :android
    j
    • 2
    • 2
  • a

    Ayomide

    01/24/2021, 1:02 PM
    Hi, this question is more about guidance because I'm not sure where to start. I have a
    TextField
    , and to highlight of the text with colours, say given a list of words to highlight. Basically - syntax highlighting. The image attached gives you an idea of what I mean. Would I have to make my own
    TextField
    component for this?
    d
    t
    s
    • 4
    • 5
  • j

    Jason Ankers

    01/24/2021, 1:57 PM
    How can I navigate from the VM in jetpack compose? say I’ve fetched some data and I need to navigate after the data has been retrieved
    k
    • 2
    • 9
  • m

    Mihai Hrincescu

    01/24/2021, 4:29 PM
    Hello everyone ! Is there a reason why we cannot create our own custom brushes by extending Brush()?
    j
    n
    • 3
    • 14
  • y

    Yashar

    01/24/2021, 5:14 PM
    Hey all. Can someone chime in for a problem I am having? I wanted to create a slider style button where additional actions are hidden beneath. The current setup is as below. And I can't get the surface below the card to register taps. Does moving the top layer card not expose tap-able surface of the view beneath?
    Box {
            Card(...) {
                Row(...)
                ) {
                    Surface(
                        modifier = Modifier
                            .fillMaxHeight()
                            .fillMaxWidth(0.5f)
                            .clickable(onClick = { ... }),
                        color = Color.Red
                    ) {
                        ...
                    }
                    Surface(modifier = Modifier.fillMaxSize().clickable(onClick = { ... }), color = Color.Blue) {
                        ...
                    }
                }
            }
    
            Card(
                modifier = Modifier
                    .fillMaxWidth()
                    .height(boxHeight)
                    .padding(horizontal = 40.dp, vertical = 16.dp)
                    .swipeable(
                        state = swipeableState,
                        anchors = anchors,
                        thresholds = { _, _ -> FractionalThreshold(0.3f) },
                        orientation = Orientation.Horizontal
                    )
                    .offset { IntOffset(swipeableState.offset.value.roundToInt(), 0) }
    
            ) {
                Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.clickable(onClick = { ... })) {
                    ...
                }
            }
    }
    offset.mp4
    m
    • 2
    • 5
  • c

    Colton Idle

    01/24/2021, 6:29 PM
    Passing
    Resources
    into a composable as a parameter? 👍 or 👎
    a
    a
    • 3
    • 12
  • o

    Orhan Tozan

    01/24/2021, 7:55 PM
    Any ETA when Compose will come to beta? Also, would a beta release be ready for production?
    r
    j
    s
    • 4
    • 5
  • j

    Jason Ankers

    01/25/2021, 7:19 AM
    Is it possible to scope a viewmodel to a navigation graph with navigation-compose?
    ➕ 1
    f
    f
    i
    • 4
    • 8
  • p

    Prashant Priyadarshi

    01/25/2021, 12:45 PM
    Has anybody tried using the modifier verticalScroll and/or scrollable to preserve the scroll position in a LazyColumn list when doing something like viewing a image in fullscreen and then coming back to list . Also how do I see the code in below package androidx.compose.foundation.samples.VerticalScrollExample
    k
    • 2
    • 2
  • l

    Lilly

    01/25/2021, 5:02 PM
    Might
    slideInVertically
    slideOutVertically
    be buggy? The initialOffsetY/ targetOffsetY should return the half of the content's height but this doesn't match. My content's height is 120 dp but value returns 376 dp 🤔
    @Composable
    fun SlideVerticallyAnimationComponent(
        visibility: Boolean,
        offset: Int,
        content: @Composable () -> Unit
    ) {
        AnimatedVisibility(
            visible = visibility,
            enter = slideInVertically(initialOffsetY = { value ->
                Timber.e("valueIn: $value") // output: 376 dp
                offset
            }) + fadeIn(),
            exit = slideOutVertically(targetOffsetY = { value ->
                Timber.e("valueOut: $value") // output: 376 dp
                offset
            }),
            content = content
        )
    }
    d
    • 2
    • 2
  • g

    Geert

    01/25/2021, 7:47 PM
    is https://gist.github.com/gildor/82ec960cc0c5873453f024870495eab3#file-jetpackcomposescaffoldsnackbar-kt-L102 the best way to close the keyboard using a button? I cant find how to create or reference my own SoftwareKeyboardController. Is there no composable function for this
    s
    • 2
    • 2
  • r

    Rick Regan

    01/25/2021, 9:39 PM
    I am trying to use a
    Text
    or
    TextField
    to display a repeating decimal, e.g., 2.(0123456789) (I am resorting to parentheses notation because to the best of knowledge, Android does not support overline, as discussed on this channel last week: https://kotlinlang.slack.com/archives/CJLTWPH7S/ ). The problem I have now is that line breaking rules will break the line after the "." (FYI it breaks up ".(" but not ".1(", for example).  I’ve been trying to look for a solution but I really only found this 9-year old one for the regular UI (and it seems like overkill in any case): https://stackoverflow.com/questions/6134457/how-to-prevent-edittext-from-breaking-a-line-after-punctuation.  What I want is a line break only when the text string (in my case digits with other characters like "(", ")", "/", "+", "-", etc.) exceeds the width of the view. Essentially I just want the line breaking rules turned off. Can this be done in Compose? (I am porting a prototype of my app that uses JavaFX, which breaks lines as I desire.)
    m
    s
    • 3
    • 11
  • e

    enighma

    01/26/2021, 2:22 AM
    I'm trying to override the
    AmbientIndication
    but it's not obvious to me what I need to do or r as there call. Do to set it up using
    Providers(...)
    ? I'm trying to change from ripple to something else.
    k
    a
    l
    • 4
    • 15
Powered by Linen
Title
e

enighma

01/26/2021, 2:22 AM
I'm trying to override the
AmbientIndication
but it's not obvious to me what I need to do or r as there call. Do to set it up using
Providers(...)
? I'm trying to change from ripple to something else.
k

Kirill Grouchnikov

01/26/2021, 2:25 AM
What is it that you're trying to achieve? Before talking about the specific solution, what is the problem?
e

enighma

01/26/2021, 2:26 AM
I want to remove the ripple effect
That or replace it with something
k

Kirill Grouchnikov

01/26/2021, 2:51 AM
For playing around, for one screen, for the entire app, for a completely custom design system?
a

Alexjlockwood

01/26/2021, 3:13 AM
you can see
MaterialTheme.kt
as a reference https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]tlin&amp;ss=androidx%2Fplatform%2Fframeworks%2Fsupport:compose%2F (but also sounds weird that you would be removing the ripple effect too tbh)
l

Louis Pullen-Freilich [G]

01/26/2021, 1:43 PM
Note that in the next release this will only be used as the default for custom components using clickable / similar gesture modifiers - this won't override the ripple used in Material components such as Button.
e

enighma

01/26/2021, 7:13 PM
@Kirill Grouchnikov ideally for the app i.e. custom design system. It's very similar to material design but designers don't like the ripples haha
@Alexjlockwood I've looked in there but it's not obvious how I would change it since the induction is set inline in a val. I want to override it because I want to implement a custom design system that almost is material design.
@Louis Pullen-Freilich [G] does that mean it won't be configurable at all?
l

Louis Pullen-Freilich [G]

01/26/2021, 7:37 PM
It is configurable, but it won't change the behavior of default components - if you want to build your own components with their own alternative to a ripple, you would need to create them yourself - this isn't a currently supported area of customization.
If your design system just wants to change colors / opacity, you can use
RippleTheme
to customize the ripples used by components, but this doesn't support replacing / changing what a ripple is.
e

enighma

01/26/2021, 9:07 PM
@Louis Pullen-Freilich [G] that answers my question what is the easiest way to override the ripple theme? Do i set another provider in my MaterialTheme scope? I tried calling rememberRipple to no avail.
l

Louis Pullen-Freilich [G]

01/26/2021, 9:33 PM
Yep you can do something like:
MaterialTheme(...) {
    Providers(AmbientRippleTheme provides MyCustomRippleTheme) {
        // rest of app
    }
}
Then anything inside this will use this ripple theme
e

enighma

01/27/2021, 1:44 AM
Awesome, let me try that :)
View count: 2