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

    Chris Fillmore

    04/06/2022, 9:44 PM
    Is anyone using
    rememberLauncherForActivityResult
    and Compose Navigation?
    a
    i
    • 3
    • 12
  • j

    julioromano

    04/06/2022, 10:23 PM
    How can I invert the luminance component of a
    Color
    ? (by invert I mean doing 1-x, in other words if luminance is 0.75 inverting it yields a luminance of 0.25). I’ve tried something like this but with little success:
    val xyz = myColor.convert(ColorSpaces.CieXyz)
    val invertedLuminance = xyz.copy(green = 1 - xyz.green)
    val result = invertedLuminance.convert(ColorSpaces.Srgb)
    r
    • 2
    • 54
  • t

    Tash

    04/06/2022, 10:47 PM
    Hi all! So far, Compose versions have been tied to Kotlin version/vice-versa until Kotlin makes compiler plugin APIs stable. Is this still true, or have there been any recent developments on this front? 🙏🏼
    👍 2
    j
    m
    c
    • 4
    • 8
  • t

    Tobias Gronbach

    04/06/2022, 11:28 PM
    Hi is it possible to let Composables "react" differently on keyboard-state (hidden/shown). In my case I want to keep a button row at the bottom below keyboard and move the rest of the screen above but I'm not sure if that's even possible. 🤔
    a
    • 2
    • 1
  • i

    Indu

    04/06/2022, 11:37 PM
    RecyclerView - ComposeView as view holder Not sure why the screen is not recomposed consistently during orientation change. When the device is rotated to landscape mode the screen sometimes displays the same width as in portrait mode for the recycler view. This does not happen all the time.
    😯 1
    • 1
    • 5
  • t

    Tin Tran

    04/07/2022, 2:49 AM
    This doc seems outdated as
    AnimatedVisibility
    is not experimental anymore
    g
    b
    • 3
    • 3
  • c

    Ch8n

    04/07/2022, 8:58 AM
    Hello, I have created a column with vertical scroll enabled, which has 5 rows having horizontal scroll enabled. Sometimes when I scroll over them very fast vertically, rows consume the swipe gesture and don't scroll and appear like the application is lagging. can someone guide me on how I can only enable row scrolling till some
    x
    amount of horizontal scroll has happened.
    video6230782002031756749.mp4
    ➕ 1
    • 1
    • 2
  • n

    nlindberg

    04/07/2022, 11:06 AM
    After updating compose to 1.2 06 alpha to get the font fixes, the text field gets its text cuttoff when adding emojies. Anyone tried anything similar and knows a fix? (without downgrading to 1.1.x) ?
    ➕ 1
    s
    • 2
    • 2
  • j

    Joseph Hawkes-Cates

    04/07/2022, 2:13 PM
    We have a view (screen 1) with an Android WebView embedded in it. We have a use case where we need to navigate to another screen (screen 2), then come back to the screen 1 with the WebView in it. We’re running into an issue with screen 1 recomposing and instantiating a new WebView. Since WebView is a little expensive to init, we were looking for a way to avoid reloading the WebView. I know it’s expected that screen 1 will go out of composition when you navigate away from it, but wanted to see if there are options to avoid that in this case. More in 🧵
    c
    • 2
    • 5
  • d

    dimsuz

    04/07/2022, 2:25 PM
    While writing a custom layout I just discovered that having some
    alignment
    value I can do
    // alignment = Alignment.Center
    val x = alignment.align(myWidth, parentWidth, LayoutDirection.Rtl)
    It's a (seemingly) small thing but very nice to not having repeat those boring
    width/2 - myWidth/2
    etc!
    👍 2
    s
    • 2
    • 2
  • s

    shivansh mittal

    04/07/2022, 7:33 PM
    Hi, I am trying to write fast, deterministic screenshot tests for compose components, I am using facebook screenshot testing library : is there a way to ComposeView to draw or generate bitmap without attaching to a window? Or any recommendation to write fast screenshot tests for jetpack compose components without starting an activity
    😯 1
    j
    t
    +2
    • 5
    • 6
  • t

    trashcoder

    04/07/2022, 8:57 PM
    Hi, I ran into a problem with setting a `Slider`'s state/position. I use `Slider`s to control the brightness of lights and the level of shutters. I store the
    Slider
    position in a variable like this:
    var shutterLevel by remember { mutableStateOf(shutter.shutterLevel) }
    And in the
    onValueChangeFinished
    event, I pass it to the API to control the device. This all works as expected, but... I also listen to events from the server. So whenever the brightness is changed through another app or the shutter level is modified with the wall switch, the
    Slider
    position does not change because it was `remember`ed. I would be really happy if anyone could help me understand what I am missing here.
    ✅ 1
    t
    • 2
    • 6
  • v

    Vladimir Tagakov

    04/07/2022, 11:23 PM
    x-posting from #compiler
    :homer-disappear: 1
    • 1
    • 1
  • k

    Karthi

    04/08/2022, 1:14 AM
    Hi, I am looking for way to add screen trace log for firebase performance metric to compose screens (similar to slow rendering/frozen frames metric of activity and fragment). Any idea where we should start and stop the trace?
    m
    • 2
    • 1
  • b

    brabo-hi

    04/08/2022, 4:40 AM
    Hi all android studio compose preview fails when using
    androidx.activity:activity-compose
    1.6.x
    but works with version
    1.4.x
    j
    • 2
    • 5
  • r

    ritesh

    04/08/2022, 8:12 AM
    Probably a very basic question. More in 🧵
    f
    • 2
    • 7
  • r

    RE

    04/08/2022, 9:13 AM
    Is there some way for compose to mix multiple types of lists? For example, the header and footer of the list are a lazycolumn, and the middle is a lazyverticalgrid. For example, If I use Paging3 with LazyVerticalGrid and I want to add a loading indicator at the bottom of the list, the indicator can only use a Grid instead of a whole row
    f
    • 2
    • 4
  • m

    Michal Klimczak

    04/08/2022, 1:23 PM
    I'm trying to add a "reset the saved bottom nav stack" on demand. Something like:
    fun NavController.navToBottomNavItem(route: String, startFromStackRoot: Boolean = false) = navigate(route) {
        //how to use [startFromStackRoot]?
        popUpTo(DashboardScreenDestination.route) {
            saveState = true
        }
        launchSingleTop = true
        restoreState = true
    }
    The scenario in our app is, there's a botom menu and there's a Dashboard stack (app starts on that) and a Shop stack. The code above makes sure that when user navigates between different bottom bar items, he isn't starting from the root of the stack, but ends up where he left. So far so good. But there's one scenario, where I want to go from Dashboard directly to the root of the Shop stack, without restoring it's state. E.g. using the
    startFromStackRoot
    param.
    i
    • 2
    • 10
  • m

    mmaillot

    04/08/2022, 2:09 PM
    Hi ! My app display a table with multiple text (see screenshot). I use LazyGridVertical. Each cell contains a text which will grow and will get bigger than the cell. Can I do what I want with my current implementation or should I use something else ? (in the exemple, if the
    meu
    grow up, it will be limited by the blue cell and I want it will be able to grow outside its cell)
    k
    • 2
    • 5
  • r

    Robert Menke

    04/08/2022, 6:23 PM
    Just released my 100% Jetpack Compose app on the play store 😛arty-parrot: thank you to the compose team for the hard work. It was truly a joy to work with ❤️ . https://twitter.com/RobertBMenke/status/1512496009808597003?s=20&t=cOH12iaSaia1isGvpBHDmQ
    👏 1
    a
    • 2
    • 3
  • s

    ste

    04/08/2022, 8:13 PM
    #rant So, am I the only one having this terrible AS performance? (not sure it's due to compose, but I don't remember facing stuff like this when I wasn't using compose)... 4 seconds to paste a short text? And no, I'm not running AS on a potato CPU usage rises to 25% for a paste
    simplescreenrecorder5-(6).mp4
    s
    t
    • 3
    • 2
  • d

    darkmoon_uk

    04/09/2022, 5:03 AM
    Is there a way to effectively exclude an element from contributing to content wrapping metrics? See this WIP layout where each 'Build' has two rows. I want to horizontally wrap to the top row i.e. the "8663, date, 3" and to disregard/truncate the Git hash below it as far as necessary.
    j
    a
    z
    • 4
    • 3
  • a

    Android75

    04/09/2022, 10:01 AM
    I am using Hilt and navigation so when inject viewmodel without parameters it works but when viewModel has other classes injected i has crash
    Caused by: java.lang.InstantiationException: java.lang.Class<com.xxx.screen.section.SViewModel> has no zero argument constructor
    n
    • 2
    • 10
  • a

    Android75

    04/09/2022, 2:35 PM
    In my custom TopAppBar i send as parameter the action…
    actions: @Composable RowScope.() -> Unit = {},
    i’d like to have different action… how can create composable function like this
    actions  = {
            IconButton(onClick = {  }) {
                Icon(imageVector = Icons.Default.Share, contentDescription = "", tint = BlueDentPad)
            }
            Icon(
                Icons.Filled.ColorLens,tint = BlueDentPad,
                contentDescription = "Localized description"
            )
        }
    • 1
    • 1
  • a

    Alexander Black

    04/09/2022, 6:25 PM
    Would anyone have any insight into why this weird view transition behavior would be happening? If it’s not clear from the video… I don’t like that odd pop up and down behavior. Any ideas/advice would be greatly appreciated. here’s my transition code:
    composable(LeafScreen.Account.route,
            enterTransition ={
                slideIntoContainer(AnimatedContentScope.SlideDirection.Right, tween(5_000))
            },
            exitTransition = {
                slideOutOfContainer(AnimatedContentScope.SlideDirection.Left, tween(5_000))
            }
            ) {....}
        composable(LeafScreen.SignIn.route,
            enterTransition ={
                slideIntoContainer(AnimatedContentScope.SlideDirection.Left, tween(5_000))
            },
            exitTransition = {
                slideOutOfContainer(AnimatedContentScope.SlideDirection.Right, tween(5_000))
            }
        ) {....}
    I’m doing this navigation from a BottomSheetScaffold… I wonder if that has something to do with it? I’m using accompanist-navigation-animation:0.24.3-alpha i’m also using androidx.navigation:navigation-compose:2.4.2
    Screen Recording 2022-04-09 at 11.21.16 AM.mov
    j
    • 2
    • 7
  • w

    willyrs

    04/09/2022, 9:08 PM
    Hello, I've just started with compose and I have a strange error.. "Composition requires an active composition context" while drawing my UI. This is the main activity:
    setContent {
        MyTheme {
            Surface(color = MaterialTheme.colors.background) {
                Column(Modifier.fillMaxHeight()) {
                    ListComposable(getList())
                }
            }
        }
    }
    The ListComposable:
    @Composable
    fun ListComposable(list: List<Info>, modifier: Modifier = Modifier) {
        LazyColumn(modifier) {
            items(items = groupedList, itemContent = { item ->
                Text(item.value) // CRASH HERE
            })
        }
    }
    I don't understand what's happening.. If I pass an empty list, it works. When it's non empty it crashes. The Info is a simple data class with just a value
    c
    • 2
    • 2
  • a

    Android75

    04/10/2022, 1:43 AM
    I ams using ExoPlayer but player don’t play but i can see video if move timeline.
    val sampleVideo = "<http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4>"
    
    val context = LocalContext.current
    val player = SimpleExoPlayer.Builder(context).build()
    val playerView = PlayerView(context)
    val mediaItem = MediaItem.fromUri(sampleVideo)
    val playWhenReady by rememberSaveable {
        mutableStateOf(true)
    }
    player.setMediaItem(mediaItem)
    playerView.player = player
    LaunchedEffect(player) {
        player.prepare()
        player.playWhenReady = playWhenReady
    
    }
    AndroidView(factory = {
        playerView
    })
    • 1
    • 2
  • i

    ignus

    04/10/2022, 7:14 AM
    Hey! Do we have possibility to check raw code generated by @Composable? I tried check Kotlin class byteCode but unfortunatelly I don't see there Composable additions.
    r
    • 2
    • 3
  • p

    Peng Wang

    04/10/2022, 12:07 PM
    https://developer.android.com/reference/kotlin/androidx/compose/runtime/Immutable
    the doc of
    @Immutable
    said that “data classes that only contain val properties that do not have custom getters can safely be marked as Immutable if the types of properties are either primitive types or also Immutable” I thought the data class with val properties should have been treated as Stable (or Immutable) by Compiler , isn’t it ? if I don’t annotate
    Person
    with `@Immutable`,means the
    PersonView
    can’t skip the unnecessary Recomposition?
    ❤️ 1
    a
    p
    h
    • 4
    • 15
  • n

    Norbi

    04/10/2022, 4:08 PM
    Is there a normal 'combobox' out of the box? Currenty I use my own simple implementation using OutlinedTextField + DropDownMenu but it's far from perfect...
    f
    a
    • 3
    • 2
Powered by Linen
Title
n

Norbi

04/10/2022, 4:08 PM
Is there a normal 'combobox' out of the box? Currenty I use my own simple implementation using OutlinedTextField + DropDownMenu but it's far from perfect...
f

Francesc

04/10/2022, 5:27 PM
Don't think so, I also needed an input field with a list of options based on the current field value and I had to roll my own using drop down menu as well. That was a while back though, but I haven't heard anything about native support being added.
👍🏻 1
a

Andrew Neal

04/10/2022, 5:59 PM
Have you seen
ExposedDropdownMenu
? https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/material/material/samples/src/main/java/androidx/compose/material/samples/ExposedDropdownMenuSamples.kt
:thank-you: 1
👀 1
View count: 5