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

    Aditya Wasan

    01/21/2022, 8:28 AM
    Hey everyone, I am drawing some rectangles in canvas and scaled them myself and that gave me the correct result. However, later I decided to use
    Modifier.scale
    on canvas instead of my original approach and that does not seem to render anything (or render too small for it to be visible) so I was wondering if that is the correct approach or not? Code in thread
    d
    • 2
    • 6
  • g

    Gerardo Ernesto Rodriguez Navar

    01/21/2022, 11:48 AM
    Hi everyone! I have a problem. I have a
    ViewHolder
    that uses compose to render, but when I click it, the whole screen jumps. Here is the video:
    d
    • 2
    • 22
  • e

    elye

    01/21/2022, 12:39 PM
    Seems like using
    derivedStateOf
    is more superior than
    remember(value)
    given it can reduce the unnecessary recomposition. I wonder is there any downside using
    remember { derivedStateOf { value } }
    as oppose to
    remember(value)
    ? More elaboration of my question in https://stackoverflow.com/questions/70801388/is-there-downside-replacing-all-remembervalue-with-remember-derivedstateof
    👀 2
    d
    z
    • 3
    • 4
  • j

    Jan Skrasek

    01/21/2022, 1:13 PM
    Compose Navigation Let's have A -> B -> C -> D nested navigation. Something like
    NavHost(startDestination = "A") {
       composable("A") {}
       navigation(startDestination = "B") {
         composable("B") {}
         navigation(startDestination = "C") {
           composable("C") {}
           composable("D") {}
         }
       }
    }
    I struggle with navigateUp(). It seems that it nicely utilize startDestination. So when deeplinking "D", navigate Up ends up in C. But when I continue with navigateUp in C, I skip to the "A", not "B" as I would expect. Is it a bug? Some debugging info in thread.
    a
    i
    • 3
    • 6
  • r

    Rahul Rawat

    01/21/2022, 1:27 PM
    I have made use of lazyColumn to display a list of data and now want to show a popup menu after clicking a triple dot button in individual row just below itself but I want the dropdown to close in case the user presses anywhere outside the dropdown for ex: clicking another row’s button. I see a lot of examples to individually show either lazyColumn or dropdown but none that combines both. Can anyone help out?
    d
    • 2
    • 5
  • b

    Brian Donovan

    01/21/2022, 2:41 PM
    Hey All, I’m not sure if this is a compose issue but I am trying to click on the blue html text to open another link inside of a web view. The post body information is in HMTL format. The information is coming from a API call. How can I do this using webView?
    f
    • 2
    • 2
  • c

    Colton Idle

    01/21/2022, 3:20 PM
    I need to create something like this in compose (essentially recreate ios' time picker). I looked already to see if anyone had one of these for compose with no luck. Anyone happen to know if something like this exists?
    n
    s
    +3
    • 6
    • 12
  • m

    myanmarking

    01/21/2022, 3:57 PM
    i need the fragment context for some legacy dialogs inside a composable.
    LocalContext.current
    is not returning me the fragment context. Is there a way to get it, without passing the context explicitly?
    c
    a
    • 3
    • 5
  • b

    brabo-hi

    01/21/2022, 5:33 PM
    Hi all, how to avoir nested NavHost when one child composable has a bottomNavBar
    NavHost(navController = navController, startDestination = "") {
            composable("viewA"){}
            composable("viewB") {}
            Scaffold(){
                NavHost(myOwnNavController, startDestination = "Child1") { // How to avoid this
                    composable("Child1") {}
                }
            }
        }
    In this example i have to use two
    NavController
    i
    • 2
    • 3
  • a

    Anthony

    01/21/2022, 5:35 PM
    Is there a way to prevent gestures on a ModalBottomSheet? I would like only a button to be able to open/close the bottom sheet and not any drag gestures.
    ➕ 1
    h
    • 2
    • 1
  • a

    Arpit Shukla

    01/21/2022, 6:27 PM
    I have a string resource that has some html tags in it. Ex.
    "This is a <b>bold</b> text."
    In View world I was able to directly use this resource and put it in a TextView as it accepts a
    CharSequence
    for text. In Compose, however, I need to create an
    AnnotatedString
    out of this resource to display it in a Text composable. How to do this?
    r
    c
    +2
    • 5
    • 5
  • e

    Esme

    01/21/2022, 7:37 PM
    I have a list displaying on a gallery in compose. Right now is showing an image and a description, when I have a big or a short description my container shrinks or grows depending of the text length, is there a way to pre-measure the texts before doing the render so that my container sets an specific height depending on how long is the text ? do you have other recommendations that could help?
    z
    • 2
    • 1
  • m

    myanmarking

    01/21/2022, 8:30 PM
    is there any way to disable paste on a TextField?
    c
    o
    • 3
    • 3
  • m

    Marco Pierucci

    01/22/2022, 5:00 AM
    Hello everyone! Im trying to achieve the following navigation with compose ( fab opens a new “screen” not associated with the bottom nav bar). Question ion the 🧵
    i
    • 2
    • 12
  • l

    linus muema

    01/22/2022, 7:50 AM
    Hi everyone, Is there a way to get all instances of a class under a composable. For example, in the image below, I want to access all instances of
    ChildState
    in the
    ParentState
    class.
    m
    • 2
    • 2
  • s

    Sanendak

    01/22/2022, 8:25 AM
    Hello everyone! In compose button event doesn't produce system tap sounds. This is a bug? Compose 1.0.5
    c
    a
    • 3
    • 2
  • h

    hfhbd

    01/22/2022, 11:43 AM
    With
    BackHandler
    and
    mutableState
    , do you still use Google androidx navigation library or simple a state based approach?
    p
    i
    • 3
    • 4
  • m

    Marcin Wisniowski

    01/22/2022, 5:53 PM
    I'm trying to achieve the equivalent of
    border-image-repeat
    from CSS, I have an image like a 9-patch drawable, except I need to repeat the borders as needed, not stretch them as 9-patch does. How would I go about that in Compose? Or should I go straight to a Canvas and implement it from scratch?
    • 1
    • 1
  • f

    Filip Wiesner

    01/22/2022, 6:32 PM
    So I was reading through the Compose runtime code and while looking at
    withMutableSnapshot
    (which has been mentioned here several times) I saw a little note at the end of the doucmentation:
    [block] must not suspend if [withMutableSnapshot] is called from a suspend function.
    Why is that? 🤔 Is it because other code can be run on the same thread when the
    block
    suspends resulting in other unrelated part of the app being in this snapshot? I am not sure I know enough about Compose and Coroutines to be sure.
    a
    • 2
    • 7
  • m

    Marcin Wisniowski

    01/22/2022, 7:08 PM
    How do I draw
    Text
    with a specific size in pixels? It seems you can only specify the size in
    sp
    and
    em
    .
    f
    • 2
    • 2
  • m

    myanmarking

    01/22/2022, 9:27 PM
    What is the proper way of showing/hiding a composable, but keeping its space so the layout doesn’t change? Currently, as the composable is selectable, i am using .alpa(if(show 1f else 0f) which works, but i feel there must be a better way
    v
    c
    +4
    • 7
    • 17
  • r

    rsktash

    01/22/2022, 11:10 PM
    I found a bug in ModalBottomSheet.
    offset
    modifier should be called before
    nestedScroll
    modifier
    v
    c
    • 3
    • 6
  • v

    Vahalaru

    01/23/2022, 12:25 AM
    Hey everyone, I'm working on a Cookbook app, and need a little guidance on what type to look into and research. On the "recipe details" screen I am making a swipeable tabbed layout one tab is ingredients the other tab is the steps to follow. How can I use the same composable too display the list of ingredients and steps on the details screen as the add recipe screen? Obviously build the composable with a plus sign icon to add a new ingredient/step and a minus and pencil icon button to remove or edit info and hide it dependent on if it is the details screen or add screen. But how would i check the state? Would i use the navcontroller or would it be better pass that info ass a parameter? Of course I could make two composables, I'm just trying to think in compose for this project.
    c
    • 2
    • 1
  • a

    Alderson Elliot

    01/23/2022, 3:42 AM
    🤕I want align right border, Is there any property to adjust the alignment anchors?
    a
    • 2
    • 1
  • m

    Mohammad Sianaki

    01/23/2022, 9:41 AM
    How Can I show a snackBar at the top of screen instead of the bottom?
    c
    a
    • 3
    • 3
  • k

    Kaushalya

    01/23/2022, 4:26 PM
    Is there any ongoing work to improve hot reload experience in Jetpack Compose?
    c
    • 2
    • 1
  • s

    Solomon Tolu Samuel

    01/23/2022, 4:56 PM
    Hello, I find my self in this situation where I have a Home screen (with a bottom navigation bar of three other screens) and a login screen. I tried having multiple navhosts like having a navhost for the entire app and another just for the home route with the bottom bar – that didn't work. I also tried nested navigation, but I am not able to utilize the NavGraphBuilder extension function in the home screen with the bottom bar. Please, do anyone have an idea of how I can structure the navigation?
    c
    • 2
    • 2
  • c

    Colton Idle

    01/23/2022, 7:37 PM
    I've seen this pattern cropping up in some compose repos from others... thoughts? At first glance I guess it's kinda clever for trying to get something to launch only once, but it just seems bad
    LaunchedEffect(key1 = "launch_once") {
        myViewModel.doSomething()
      }
    s
    a
    • 3
    • 5
  • l

    Lukasz Kalnik

    01/23/2022, 9:36 PM
    I'm using Coil to load an image into a layout with dynamic height:
    Column {
                Image(
                    painter = rememberImagePainter(backdropImageUrl),
                    contentDescription = null,
                    contentScale = ContentScale.Crop,
                    modifier = Modifier.fillMaxWidth(),
                )
        }
    However it doesn't render anything. The only way to make it work is like this:
    Column {
                Image(
                    painter = rememberImagePainter(backdropImageUrl) {
                        size(OriginalSize)
                    },
                    contentDescription = null,
                    contentScale = ContentScale.Crop,
                    modifier = Modifier.fillMaxWidth(),
                )
        }
    Is it correct? Can't Coil just automatically predict the size of the image based on the width (and calculate the height from it based on the aspect ratio)? It is really a super basic use case, would be nice to have some sensible default behavior for it.
    i
    c
    • 3
    • 5
  • b

    brabo-hi

    01/24/2022, 4:18 AM
    Hi all, when using accompanist permission, could we call
    rememberPermissionState
    within a compose?
    • 1
    • 2
Powered by Linen
Title
b

brabo-hi

01/24/2022, 4:18 AM
Hi all, when using accompanist permission, could we call
rememberPermissionState
within a compose?
When doing this
@OptIn(ExperimentalPermissionsApi::class)
@Composable
@Preview
fun MyPreview() {
    val cameraPermissionState = rememberPermissionState(android.Manifest.permission.CAMERA)
}
I have the preview error
java.lang.IllegalStateException: Permissions should be called in the context of an Activity
View count: 6