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

    karn

    04/27/2021, 1:13 AM
    Hey folks, has anyone seeing an error like this once you add compose to a project with kotlin-serialization?
    java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
    	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
    	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
    	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
    	at java.base/java.util.Objects.checkIndex(Objects.java:372)
    	at java.base/java.util.ArrayList.get(ArrayList.java:459)
    	at org.jetbrains.kotlinx.serialization.compiler.backend.ir.IrBuilderExtension$serializerInstance$1.invoke(GeneratorHelpers.kt:593)
    	at org.jetbrains.kotlinx.serialization.compiler.backend.ir.IrBuilderExtension$serializerInstance$1.invoke(GeneratorHelpers.kt:592)
    	at org.jetbrains.kotlinx.serialization.compiler.backend.ir.IrBuilderExtension$DefaultImpls.serializerInstance(GeneratorHelpers.kt:609)
        ...
    c
    r
    • 3
    • 6
  • k

    Kai Zhu

    04/27/2021, 1:21 AM
    Seems outdated. https://developer.android.com/jetpack/compose/layout#intrinsic-measurements
    ➕ 2
    l
    • 2
    • 1
  • a

    Ahmed Mourad

    04/27/2021, 3:35 AM
    Hey everyone! I'm using 
    Canvas
     and I'm trying to draw text inside a "balloon", but 
    DrawScope
     doesn't seem to have a 
    drawText
     method, the only way to draw text seems to be:
    drawIntoCanvas { 
        it.nativeCanvas.drawText(...)
    }
    Which is buried deep enough that it's probably bad to use. What are the alternatives to this? I also need to have the dimensions of the drawn text in order to wrap the "balloon" around it.
    z
    d
    p
    • 4
    • 9
  • z

    Zach Klippenstein (he/him) [MOD]

    04/27/2021, 3:48 AM
    There seem to have been lots of questions the last couple days about doing fancy stuff when drawing inside canvases. I am sure every case is unique, but I wonder how many, if any, are situations where the only reason to use a canvas was because classic Android was too clunky and heavyweight to create custom views, but could be done effectively with compose’s layout system, a couple custom composables, and a custom
    Layout
    , since there’s relatively so little overhead (both code boilerplate and no giant View class to worry about). In other words, embracing and leveraging compose’s tools instead of trying to work around them. Then problems like how to draw shadows, text, etc would be much simpler because they’d be done using the regular compose APIs.
    👏 2
    ➕ 10
    c
    p
    • 3
    • 4
  • q

    Quentin Dommerc

    04/27/2021, 6:43 AM
    👋 Hey, so friends of mine are having a weird issue with ripple on my app, and I can’t repro it on my phone(s). The ripple are never disappearing. I’m on 1.0.0-beta05. Has anyone hear of an issue like that?
    👀 2
    👍 1
    a
    e
    n
    • 4
    • 7
  • c

    Colton Idle

    04/27/2021, 7:41 AM
    Has anyone here enabled Gradle configuration cache and got it to work with compose? When I enable it and touch something in compose I get a nice long stacktrace, but curious if it's expected. I'll likely file a bug and attach in this thread. Anyone from the AGP team find this interesting?
    com.android.build.gradle.internal.utils.KgpUtils$addComposeArgsToKotlinCompile$1.execute(kgpUtils.kt:139)
    • 1
    • 1
  • y

    Yuki Anzai

    04/27/2021, 7:46 AM
    Hi. Is it possible to center text in BasicTextField ?
    m
    • 2
    • 2
  • c

    Cicero

    04/27/2021, 9:21 AM
    Hey people, I've been delaying this question as I'm trying to find why it happens before I ask it. But as I'm sitting at the doctor and I can't debug anything, here we go: What happens if you try to add an Image with a resourceAsPaint(Tiny icon here) and a Text("whatever text here") , inside of a Button{here}? I have a weird scenario that doesn't matter if I pot them in a row or not and how I set my horizontal and vertical alignments to center. The text is always aligned top and the image bottom. I really wish not to go hacky here and just padd the object into position as I would appreciate it to take its measurements from the text size and padding. Would anyone have any clues?
    a
    c
    +2
    • 5
    • 16
  • m

    mzgreen

    04/27/2021, 10:52 AM
    How do I draw a
    Box
    with a border on only one side?
    👀 1
    z
    n
    • 3
    • 5
  • f

    Felipe Passos

    04/27/2021, 11:01 AM
    Hello, I'm trying to pass a state to the navigation for me to use in the screen, i tried just passing the location to the navhost but it does not update when the variable does so i found it out about this hilt thing, but i'm getting a runtime error..
    :thread-please: 2
    c
    a
    j
    • 4
    • 11
  • a

    Arun

    04/27/2021, 11:59 AM
    Fatal Exception: java.lang.IllegalStateException
    Cannot create Typeface from ResourceFont(resId=2131296258, weight=FontWeight(weight=600), style=Normal)
    I’m using a custom font. This is working fine on Android 11 but crashing on Android 10. Any idea why?
    ➕ 2
    a
    s
    +3
    • 6
    • 11
  • c

    Colton Idle

    04/27/2021, 12:57 PM
    If I want my composable to take in a list of other composables. For example, I want to take in a list of buttons, and depending on the state of my composable, I will show one of the buttons via
    buttonList[selected]()
    I thought defining an argument into my composable like this would work
    buttonList: List<@Composable ColumnScope.() -> Unit>
    but then sending in a
    listOf(CustomButton(), CustomButton2())
    doesn't actually work. Thoughts?
    z
    a
    t
    • 4
    • 8
  • e

    escodro

    04/27/2021, 12:58 PM
    Hello, everybody! 👋 Quick question regarding
    DisposableEffect
    . I have a
    ModalBottomSheetLayout
    with different contents based on user interaction. My idea is to clean all the content and clear the focus when the BottomSheet is hidden. My current implementation is:
    DisposableEffect(modalSheetState.currentValue) {
        onDispose {
            if (modalSheetState.isVisible.not()) {
                focusManager.clearFocus()
                sheetContentState = SheetContentState.Empty
            }
        }
    }
    The code is working, but in all samples I see there is a code before
    onDispose()
    , like a callback register. Is it a correct implementation of
    DisposableEffect
    ? Thanks a lot for your help! ❤️
    z
    a
    s
    • 4
    • 22
  • j

    Justin Tullgren

    04/27/2021, 2:48 PM
    Hi, what composable or modifier can i use to control layout positioning? I am messing with the compose Greeting Tutorial and I added a TopAppBar and the composables are stacking on top of eachother instead of laying out sequentially. Thanks!
    f
    k
    • 3
    • 12
  • c

    Colton Idle

    04/27/2021, 2:57 PM
    Scrollable tabs on https://material.io/components/tabs#usage don't seem to have leading padding (left image), but the compose tabs do seem to have some sort of leading padding (right image). Is that by design or a bug? If it's by design, is there a way to get rid of it?
    d
    l
    • 3
    • 9
  • c

    Colton Idle

    04/27/2021, 3:54 PM
    Anyone just see an infinite spinner on "Initializing"? This seems to have started when I started using Gradle 7. Will try to see if a minimal repro project with latest everything, gradle 7, kotlin 1.4.32 will repro the issue.
    d
    • 2
    • 3
  • a

    alorma

    04/27/2021, 4:26 PM
    Hello dear composable friends! a bit of spam from my side... I just deployed the first (usable) version of a new library i was building for Compose: https://github.com/alorma/Compose-Settings Any feedback will be apreciated
    ❤️ 7
    :android-new: 5
    🎉 7
    • 1
    • 1
  • m

    MBegemot

    04/27/2021, 4:59 PM
    Is it planed to do a scroll bar some day? If so I'll wait if not I'll try myself. tnks
    z
    • 2
    • 2
  • d

    David Edwards

    04/27/2021, 5:20 PM
    I have been working on a project over the last month or so after work. It is called Assemble, and it is for a game called DDO. Source and store link to follow in thread.
    👍 4
    🎉 2
    c
    • 2
    • 7
  • n

    Nat Strangerweather

    04/27/2021, 7:44 PM
    Hi, I have several tiles (roundedcornershape) that I can move around. Is there a way of making them solid, so that I can't drag one over another?
    h
    • 2
    • 4
  • d

    dewildte

    04/27/2021, 9:16 PM
    Would be great if Material.io was updated to include Compose.
    ☝️ 4
    ➕ 26
    l
    c
    • 3
    • 3
  • a

    allan.conda

    04/28/2021, 2:41 AM
    [compose-navigation] Given an authentication flow in an app, which can go deeper with sign ups, mfa and stuff, how should I go about on going back to the auth-required screen with compose? I was looking to use something like
    navController.popBackstack(route="authParent")
    but there’s no API like that. I can’t point to a specific route from the navigation flow because the app can navigate to Auth from different screens.
    i
    j
    • 3
    • 23
  • l

    Luis Daivid

    04/28/2021, 6:50 AM
    When there is one circle, I want to give different animations for each time section. For example, I want to increase the circle size in 0-3 seconds, move the x-coordinate to the right in 3-6 seconds, and reduce the size again in 6-9 seconds. How to do it?
    a
    z
    • 3
    • 13
  • a

    Alexandru Hadăr

    04/28/2021, 9:49 AM
    👋🏻 Do you know, is there any way I can configure a TextField to be LTR by default? I want to start writing from the right side and keep the cursor on that side, like this:
    m
    • 2
    • 2
  • e

    escodro

    04/28/2021, 11:04 AM
    Hello, everyone! 👋 I’m having an issue with Experimental
    ModalBottomSheetLayout
    and screen orientation. If I open the
    BottomSheet
    in landscape and rotate the screen the app crashes with error
    The initial value must have an associated anchor
    . An issue tracker was already open for further investigation, but is there any workaround in the meantime? Basically this is the only issue that is preventing me to release my app on Google Play. 😊 Thanks a lot for all your help! ❤️
    😒ame: 1
    a
    • 2
    • 1
  • n

    Nthily

    04/28/2021, 12:20 PM
    Hi there, I found in the documentation that Modifier.requiredWidth() is used to modify the width of the Row, but I can use Modifier.width() to achieve the same effect, what is the difference between them?
    m
    • 2
    • 2
  • c

    Cyril Find

    04/28/2021, 12:24 PM
    Hi composers 👋 : I have a small component with a
    draggable
    modifier and i'd like the touch zone to be a bit larger than its bounds but I have no idea how to do that ?
    m
    • 2
    • 4
  • f

    Felipe Passos

    04/28/2021, 1:16 PM
    Hello, i'm trying to import a svg like this :
    Icon(
                    painter = painterResource(id = R.drawable.ic_taxi),
                        contentDescription = "",
                Modifier
                    .height(200.dp)
                    .width(200.dp)
            )
    The svg have multiple colors on it but for some reason the displayed image is full black
    p
    g
    • 3
    • 8
  • l

    loloof64

    04/28/2021, 1:58 PM
    Hi ! I've got a strange issue with Android Studio (Artic Fox). But trying invalidating cache and rebuilding project did not help. Excerpt of stacktrace in thread.
    c
    • 2
    • 5
  • m

    MaxUt

    04/28/2021, 2:03 PM
    Hi there, is there a way to convert Bitmap into ImageBitmap ? I would like to use the Image composable to display images that are stored locally. My idea was to use
    BitmapFactory.decodeFile(MY_FILE_PATH)
    to convert the images into Bitmap first and then from Bitmap to ImageBitmap
    n
    a
    +2
    • 5
    • 15
Powered by Linen
Title
m

MaxUt

04/28/2021, 2:03 PM
Hi there, is there a way to convert Bitmap into ImageBitmap ? I would like to use the Image composable to display images that are stored locally. My idea was to use
BitmapFactory.decodeFile(MY_FILE_PATH)
to convert the images into Bitmap first and then from Bitmap to ImageBitmap
n

Nthily

04/28/2021, 2:23 PM
The way to handle it now is that you can use the Glide or Coil libraries to load them
https://github.com/google/accompanist/tree/main/coil
https://github.com/google/accompanist/tree/main/glide
CoilImage(Uri.fromFile(path...), null)
m

MaxUt

04/28/2021, 2:25 PM
Amazing, thanks so much 🙂
a

Adam Powell

04/28/2021, 2:35 PM
if you already have an android
Bitmap
you can use the
.asImageBitmap()
extension: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#asimagebitmap
m

MBegemot

04/28/2021, 2:35 PM
BitmapFactory.decodeByteArray(localByteArray, 0, locakByteArray.size).asImageBitmap()
and yo don't need anything else
a

Adam Powell

04/28/2021, 2:35 PM
but the reason to use something like coil or glide is to handle cache scoping; reloading and re-decoding the same bitmaps over and over will tank performance
n

Nthily

04/28/2021, 2:36 PM
ufff i see
m

MBegemot

04/28/2021, 2:36 PM
that's why you put them in a hassmap
a

Adam Powell

04/28/2021, 2:36 PM
and then design a cache eviction policy, etc. 🙂
you can absolutely do it yourself, but tuning it is more work than it looks like at first.
m

MaxUt

04/28/2021, 2:38 PM
@Adam Powell so you're not recommending the use of Coil or Glide ?
a

Adam Powell

04/28/2021, 2:42 PM
I am recommending using them for their cache management. I am not recommending using them if you already have that problem space handled in some other way.
c

Chachako

04/28/2021, 5:25 PM
If you just want to convert Bitmap to ImageBitmap, use
.asImageBitmap()
, which is very easy. If you want to load a Bitmap and use it with Coil's or Gilde's many out-of-the-box features, you can use
accompanist
, otherwise you can simply use
.asImageBitmap()
, and apply it to an Image.
View count: 1