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

    Denis

    03/05/2021, 6:25 PM
    Does anybody know where I can find code for
    DataTable
    that was removed last year?
    ➕ 1
    a
    3 replies · 2 participants
  • n

    Nikola Drljaca

    03/05/2021, 7:46 PM
    Is there any way to grab arguments inside a
    viewModel
    when using
    navigation-compose
    ?
    i
    g
    +1
    16 replies · 4 participants
  • g

    gpaligot

    03/05/2021, 8:45 PM
    Hey folks! I’m trying to add a shadow to a
    Box
    with a
    CircleShape
    . My shadow is displayed but it isn’t the same shadow applied around all my shape. Can it be possible to avoid a bigger shadow at the bottom and to have the exact same shadow around all the box?
    @Composable
    fun CircleProgress(
        angle: Int
    ) {
        Box(
            Modifier
                .fillMaxSize()
                .padding(80.dp)
                .shadow(elevation = 8.dp, shape = CircleShape)
                .background(color = Color.White, shape = CircleShape)
                .padding(10.dp)
                .drawBehind {
                    drawArc(
                        color = Color.Red,
                        startAngle = -90f,
                        sweepAngle = angle.toFloat(),
                        useCenter = false,
                        style = Stroke(width = 30f, cap = StrokeCap.Round)
                    )
                }
        )
    }
    Thanks in advance!
    r
    8 replies · 2 participants
  • v

    Vivek Sharma

    03/05/2021, 8:51 PM
    var state1 by remember { mutableStateOf(1) }
    var state2 by remember { mutableStateOf(100 - state1) }
    I am having kind of this code, I am updating
    state1
    and
    state2 should update when state1 update
    , but
    state2 is not getting updated
    , am I doing something wrong?
    d
    2 replies · 2 participants
  • m

    Mehdi Haghgoo

    03/05/2021, 9:12 PM
    I have a composable that is responsible to return a color in sequence from an array each time called. To make it work in sequence and remember what it returned last time, I added remember{mutableStateOf()}. I am using this composable to draw a group of boxes in another composable. The problem is the colors start to flicker in a scary way! Any idea why this happens?
    boxes.mp4
    z
    6 replies · 2 participants
  • y

    yahyabayramoglu

    03/05/2021, 9:20 PM
    Is there an easy way to center a composable inside a
    Card
    ? 😅 Card has fixed size, and it only contains a Text which needs to be centered. This is literally the only way I could get it work - I must be doing something wrong here 🙂
    Card(modifier = Modifier.size(50.dp).padding(4.dp)) {
        Row(verticalAlignment = Alignment.CenterVertically) {
              Text(
                    text = "10",
                    textAlign = TextAlign.Center,
                    fontSize = 10.sp,
                    modifier = Modifier.fillMaxWidth()
               )
         }
    }
    m
    l
    4 replies · 3 participants
  • l

    Law Gimenez

    03/06/2021, 7:10 AM
    I was going through the Jetpack Tutorial and it seems it wasn’t updated yet because I can’t seem to find
    Modifier.preferredHeight(16.dp)
    . So what is the fix for this?
    j
    k
    +1
    4 replies · 4 participants
  • s

    Sudhir Singh Khanger

    03/06/2021, 8:42 AM
    I am not able to use
    MaterialTheme.colors.onSurface
    in a Composable. Cursor hover tells me
    org.jetbrains.kotlin.diagnostics.SimpleDiagnostic@9406416a (error: could not render message)
    whereas the build window tells me
    @Composable invocations can only happen from the context of a @Composable function
    But I am using it inside a Composable function.
    f
    t
    4 replies · 3 participants
  • s

    Shivam Sethi

    03/06/2021, 8:50 AM
    Hello, what is the equivalent function of swifui view's on appear closure in compose, I want to perform certain action when composable appear on screen?
    h
    a
    2 replies · 3 participants
  • e

    elye

    03/06/2021, 10:45 AM
    Anyone face this problem on the latest Jetpack Compose Beta? https://stackoverflow.com/questions/66504783/cannot-access-setcontent-it-is-internal-in-androidx-compose-ui-platform
    n
    s
    5 replies · 3 participants
  • b

    Bradleycorn

    03/06/2021, 2:22 PM
    If I have a
    Column
    and I want it's content to be centered (vertically) on the screen, I can do:
    Column(modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center) { ... }
    But what if I don't want it centered vertically, but instead want (the top of) it to be offest 35% from the top of the screen? I can use the
    offset
    modifier (
    offset(y=100.dp)
    ) to place it a certain amount from the top, but I want to specify the offset by percentage, not dp ...
    a
    a
    12 replies · 3 participants
  • j

    jaqxues

    03/06/2021, 5:01 PM
    How can I animate switching from dark to light theme (without using animate on every single color on the theme)
    d
    a
    12 replies · 3 participants
  • g

    Gabriel

    03/06/2021, 7:21 PM
    I have a
    composeable
    inside a
    navhost
    that takes an arg as part of it's route, I can get it as part of the arguments passed to the composable, but when I try to get it from the viewmodel inside a
    @Composable
    it's not present, https://gist.github.com/gabriel403/61c149a491e7701314b6a895e1a48df0
    i
    3 replies · 2 participants
  • a

    A. Sachdeva

    03/06/2021, 7:53 PM
    hi, i opened a new project and my editor seems to give no preview for any function. how can i fix this?
    ✅ 1
    g
    m
    +1
    9 replies · 4 participants
  • s

    Shivam Sethi

    03/06/2021, 10:19 PM
    Does compose navigation support any animation/transition behavior while navigating ?
    j
    i
    2 replies · 3 participants
  • r

    Rick Regan

    03/07/2021, 12:40 AM
    How do you get a
    Button
    to respond to both a press and a long press? I tried modifier
    .pointerInput
    with
    detectTapGestures
    and
    onLongPress
    but it does not detect the long press (or any of the other gestures). If I include a
    Text
    in the Button I can get the long press to work on the text portion, but I want to cover the whole button. (See code in thread.) Edit: I can't get
    Modifier.combinedClickable
    to do it either (see second code example in thread).
    ➕ 1
    d
    6 replies · 2 participants
  • k

    Konyaco

    03/07/2021, 5:20 AM
    https://issuetracker.google.com/181968398 Animation doesn't work when durationMillis >= 4295
    d
    5 replies · 2 participants
  • s

    Shivam Sethi

    03/07/2021, 7:26 AM
    any idea why I am not able to use Modifier.weight() modifier, it shows that in red
    d
    t
    3 replies · 3 participants
  • o

    Olivier Patry

    03/07/2021, 11:37 AM
    I had an unexpected behavior, I'd consider it as a bug, but maybe there is a reason for that. Using the
    BackdropScaffold
    with a nullable front content. The front content is well displayed when not null, then when state is updated to
    null
    previous state remains.
    @Composable
    fun AppScreen() {
        val viewModel = viewModel()
        val state by viewModel.state.observeAsState(null)
    
        BackdropScaffold(
            appBar = { },
            backLayerContent = {
                Column(
                    Modifier.fillMaxWidth()
                ) {
                    //
                    Text("BACK")
                }
            },
            frontLayerContent = {
                state?.let { uiState ->
                    Text("FRONT")
                }
            }
        )
    }
    To workaround this, I had to add an empty box:
    state?.let { uiState ->
        Text("FRONT")
    } ?: Box {}
    Is it expected? When the state is null at the beginning nothing is displayed as expected without the workaround.
    n
    1 reply · 2 participants
  • i

    Issa

    03/07/2021, 11:56 AM
    While taking the
    Pathway
    first code lab
    Compose Basics
    section
    Animating your list
    I have noticed that
    LazyColumn
    doesn’t remember the
    isSelected
    state of the item when recomposing. I have copy pasted the code from the
    Pathway
    and got the same results. Just when you scroll until the item is no more visible, when you scroll back the
    isSelected
    state is lost. IMO this is wrong cuz the state should be cached anyway and when recomposing the compiler should consider the previous state. Should I
    Hoist
    the state of the
    Greeting
    widget so I can manage it in the
    LazyColumn
    scope or this is just a Compose
    Bug
    ?
    🤔 Thanks in advance!
    j
    j
    +1
    15 replies · 4 participants
  • s

    Slackbot

    03/07/2021, 12:36 PM
    This message was deleted.
    d
    m
    5 replies · 3 participants
  • m

    Mjahangiry75

    03/07/2021, 12:36 PM
    hello everyone, I'm getting this error and I have no idea to fix it
    E/AndroidRuntime(21544): Process: co.newgates.speechtype, PID: 21544
    E/AndroidRuntime(21544): java.lang.ArrayIndexOutOfBoundsException: length=5120; index=-2
    E/AndroidRuntime(21544):        at androidx.compose.runtime.SlotTableKt.groupSize(SlotTable.kt:2558)
    E/AndroidRuntime(21544):        at androidx.compose.runtime.SlotTableKt.access$groupSize(SlotTable.kt:1)
    E/AndroidRuntime(21544):        at androidx.compose.runtime.SlotReader.groupSize(SlotTable.kt:596)
    E/AndroidRuntime(21544):        at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2215)
    E/AndroidRuntime(21544):        at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2499)
    E/AndroidRuntime(21544):        at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:2625)
    E/AndroidRuntime(21544):        at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:406)
    E/AndroidRuntime(21544):        at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:724)
    E/AndroidRuntime(21544):        at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:100)
    E/AndroidRuntime(21544):        at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:437)
    E/AndroidRuntime(21544):        at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:411)
    E/AndroidRuntime(21544):        at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34)
    E/AndroidRuntime(21544):        at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:112)
    E/AndroidRuntime(21544):        at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:43)
    E/AndroidRuntime(21544):        at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:72)
    E/AndroidRuntime(21544):        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:765)
    E/AndroidRuntime(21544):        at android.view.Choreographer.doCallbacks(Choreographer.java:580)
    E/AndroidRuntime(21544):        at android.view.Choreographer.doFrame(Choreographer.java:549)
    E/AndroidRuntime(21544):        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
    E/AndroidRuntime(21544):        at android.os.Handler.handleCallback(Handler.java:739)
    E/AndroidRuntime(21544):        at android.os.Handler.dispatchMessage(Handler.java:95)
    E/AndroidRuntime(21544):        at android.os.Looper.loop(Looper.java:135)
    E/AndroidRuntime(21544):        at android.app.ActivityThread.main(ActivityThread.java:5221)
    E/AndroidRuntime(21544):        at java.lang.reflect.Method.invoke(Native Method)
    E/AndroidRuntime(21544):        at java.lang.reflect.Method.invoke(Method.java:372)
    E/AndroidRuntime(21544):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    E/AndroidRuntime(21544):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
    :thread-please: 1
    j
    1 reply · 2 participants
  • f

    florent

    03/07/2021, 12:53 PM
    Hi everyone, I did https://developer.android.com/codelabs/jetpack-compose-state?continue=https%3A%2F%2Fdev[…]2Fdeveloper.android.com%2Fcodelabs%2Fjetpack-compose-state yesterday and it doesn't work, I did the exercise step by step and also tried the finished version on my phone. When I try to edit and change the text, I can only type one letter, do you know how to fix that? Thanks!
    d
    10 replies · 2 participants
  • m

    msomu

    03/07/2021, 2:08 PM
    When I’m trying to use
    AnimatedVisibility
    I’m getting this error
    org.jetbrains.kotlin.diagnostics.SimpleDiagnostic@4ae249ce (error: could not render message)
    am I missing something? I have added these annotations
    @ExperimentalAnimationApi
    or
    @OptIn(ExperimentalAnimationApi::class)
    j
    d
    3 replies · 3 participants
  • c

    Can

    03/07/2021, 3:04 PM
    Hey people! I feel like I'm missing something here. I'd like to apply a Porterduffmode / BlendMode to a Text so that it changes the color so that the lower half is white for example. Previously this could be achieved with "drawText" and a Porterduffmode but DrawScope doesn't support drawText and I feel like i can't apply a ColorFilter to Text. There might be some way by writing a custom Painter and add a colorfilter to it but this doesn't feel like a straightforward way to do this. Any ideas?
    d
    a
    +2
    14 replies · 5 participants
  • d

    Daniel

    03/07/2021, 3:42 PM
    The docs for
    BlendMode.SrcIn
    appear to be incorrect.
    Show the source image, but only where the two images overlap. 
    The destination image is not rendered, it is treated merely as a mask. 
    The color channels of the destination are ignored, only the opacity has an effect
    The color channels of the destination are used. Assuming this just wraps the native equivalent, this would be the expected behavior. Asking here to check I'm not missing something stupid before I file a bug.
    r
    24 replies · 2 participants
  • p

    Piotr Prus

    03/07/2021, 7:58 PM
    I have this strange error that do not point to anything in my code and it crashes the app. I have Bottom Navigation, where one fragment (start destination) is 100% done in compose. When I start the app everything works fine, but when I go to other fragment and go back to my main (compose), I got this crash. Anyone saw something like this before?
    java.lang.NullPointerException: Attempt to invoke interface method 'void androidx.compose.runtime.MutableState.setValue(java.lang.Object)' on a null object reference
            at androidx.compose.ui.platform.AndroidComposeView.setLayoutDirection(AndroidComposeView.android.kt:930)
            at androidx.compose.ui.platform.AndroidComposeView.onRtlPropertiesChanged(AndroidComposeView.android.kt:768)
            at android.view.View.resolvePadding(View.java:20272)
            at android.view.ViewGroup.resolvePadding(ViewGroup.java:7765)
            at android.view.View.initializeScrollbarsInternal(View.java:6781)
            at android.view.View.<init>(View.java:6112)
            at android.view.ViewGroup.<init>(ViewGroup.java:697)
            at android.view.ViewGroup.<init>(ViewGroup.java:693)
            at android.view.ViewGroup.<init>(ViewGroup.java:689)
            at android.view.ViewGroup.<init>(ViewGroup.java:685)
            at androidx.compose.ui.platform.AndroidComposeView.<init>(AndroidComposeView.android.kt:115)
            at androidx.compose.ui.platform.Wrapper_androidKt.setContent(Wrapper.android.kt:79)
            at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:175)
            at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:207)
            at android.view.View.dispatchAttachedToWindow(View.java:20479)
            at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3489)
            at android.view.ViewGroup.addViewInner(ViewGroup.java:5278)
            at android.view.ViewGroup.addView(ViewGroup.java:5064)
            at androidx.fragment.app.FragmentContainerView.addView(FragmentContainerView.java:290)
            at android.view.ViewGroup.addView(ViewGroup.java:5004)
            at androidx.fragment.app.FragmentStateManager.addViewToContainer(FragmentStateManager.java:830)
            at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:520)
            at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
            at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177)
            at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2094)
            at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990)
            at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
            at android.os.Handler.handleCallback(Handler.java:938)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:223)
            at android.app.ActivityThread.main(ActivityThread.java:7660)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
    a
    c
    +1
    13 replies · 4 participants
  • s

    Shivam Sethi

    03/07/2021, 11:02 PM
    What is the correct way of passing constructor arguments to compose view model using viewModel() in a composable?
    👀 1
    i
    9 replies · 2 participants
  • e

    efemoney

    03/07/2021, 11:02 PM
    If I have a composable that is [0, 0, X, Y] size big and I wanted to clip it to display (and also report its size as) only a small part of that, how would I achieve that ? Say my composable reports its size as 100 x 100 but its children/content have a 500 x 500 canvas to draw on and I can select what area within that 500 x 500 canvas is visible in that 100 x 100 window 🤔
    d
    1 reply · 2 participants
  • a

    Alexjlockwood

    03/08/2021, 1:53 AM
    how can i get access to a given
    Text
    composable’s
    ascent
    and
    descent
    font metrics? there seems to be an API to access a text line’s
    top
    and
    bottom
    in
    TextLayoutResult
    , but nothing for
    ascent
    and
    descent
    https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]ult.kt;l=260-274;drc=75473ddf27998fdb2105416a5f0505f492ee8ad5 or is there a different API that i need to use? 🤔 cc @Siyamed
    d
    s
    +3
    6 replies · 6 participants
Powered by Linen
Title
a

Alexjlockwood

03/08/2021, 1:53 AM
how can i get access to a given
Text
composable’s
ascent
and
descent
font metrics? there seems to be an API to access a text line’s
top
and
bottom
in
TextLayoutResult
, but nothing for
ascent
and
descent
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]ult.kt;l=260-274;drc=75473ddf27998fdb2105416a5f0505f492ee8ad5 or is there a different API that i need to use? 🤔 cc @Siyamed
d

Denis

03/08/2021, 5:21 AM
(not an answer) I didn't know what ascent/descent meant in the context, and I've found a great answer here https://stackoverflow.com/questions/27631736/meaning-of-top-ascent-baseline-descent-bottom-and-leading-in-androids-font.
s

Siyamed

03/08/2021, 5:14 PM
Hi Alex, can you please create a ticket about this?
a

Alexjlockwood

03/08/2021, 5:16 PM
i had a while ago 🙂 https://issuetracker.google.com/issues/173648606 was just wondering if there were any updates since then
😕 1
c

Colton Idle

03/09/2021, 1:11 AM
⭐ added 😄
o

orangy

08/29/2021, 8:17 PM
I need it too, though I need cap height
s

saket

06/27/2022, 8:35 PM
Can we please get some attention to this feature request? Custom text drawing is very difficult in compose ui right now.
View count: 1