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

    Mohammad Jahidul Islam

    08/13/2021, 4:48 AM
    @Composable fun VideoPlayer(sourceUrl: String) { val context = LocalContext.current val player = SimpleExoPlayer.Builder(context).build() val mediaItem = MediaItem.fromUri(sourceUrl) player.setMediaItem(mediaItem) player.prepare() player.play() AndroidView( factory = { context -> PlayerView(context).apply { setPlayer(player) } } ) }
    :kotlin-intensifies: 3
    ‼️ 5
    ❓ 9
    r
    • 2
    • 4
  • d

    Deepak Gahlot

    08/13/2021, 7:05 AM
    Hello All, How do we clear the backstack in the navigation for compose. Before the beta07 there was a method called navController.backstack.clear. Now i see that is being removed. and something like backQueue.clear() is there. Is it the same thing ?
    a
    i
    • 3
    • 2
  • j

    Jeff

    08/13/2021, 9:29 AM
    Anyone come across this error
    java.lang.ClassCastException: androidx.fragment.app.FragmentViewLifecycleOwner cannot be cast to androidx.activity.ComponentActivity
    I'm using setContent with the latest
    activity-compose
    a
    • 2
    • 1
  • d

    dimsuz

    08/13/2021, 10:31 AM
    If I have this
    Box {
      Image(contentScale = FillBounds, painter = painterResource(R.drawable.myPng))
      Content() // can by of various height depending on the children
    }
    How do I make the image fill the same height as
    Content()
    . Currently
    Image
    gets only as big as its resource, ignoring FillBounds flag
    f
    • 2
    • 2
  • k

    Karim Hassan

    08/13/2021, 10:34 AM
    Does mutableStateOf() emit the initial value in composition if the state hasn’t changed ? and if so, how to stop that ?
    KViewModel.kt
    
    var errorState by mutableState<Error>(Error("")) 
    private set 
    var successState by mutableState<Success>(Success(""))
    private set
    
    fetchData(){
       viewModelScope.launch {
       when(val result = repo.fetchData){
           Result.success -> successState = result.data
           Result.error ->  errorState = result.error
       }
    }
    }
    
    in Screen.kt 
    @Composable
    fun Screen(viewModel :  KViewModel )  {
       
        ShowData(viewModel.successState)
        ShowError(viewModel.errorState)
    }
    m
    z
    a
    • 4
    • 8
  • d

    dan.the.man

    08/13/2021, 3:43 PM
    Someone posted a solution like
    LazyColumn(
        modifier = Modifier.fillMaxSize(),
    ) {
        // My Books section
        item {
            Column(modifier = Modifier.fillMaxWidth()) {
                Text("My Books")
                LazyRow {
                    items(books) { item ->
                        // Each Item
                    }
                }
            }
    
        }
        // Whishlisted Books title
        item {
            Text("Whishlisted Books", style = MaterialTheme.typography.h4)
        }
        // Turning the list in a list of lists of two elements each
        items(wishlisted.windowed(2, 2, true)) { item ->
            Row {
                // Draw item[0]
                // Draw item[1]
            }
        }
    }
    to a SO question, but what is the point of multiple
    item{}
    blocks instead of just having it all in one?
    v
    k
    c
    • 4
    • 5
  • t

    theapache64

    08/13/2021, 4:47 PM
    🧭 Accompanist’s `bottomSheet` ’s navEntry not maintained ( Details inside 🧵)
    c
    j
    +2
    • 5
    • 16
  • a

    Artem

    08/13/2021, 6:59 PM
    Does anyone know how to fix nested scroll issue? I have`ComposeView` as a root view inside
    BottomSheetDialogFragment
    and inside that
    ComposeView
    there are
    verticalScroll()
    and scroll works properly only when it reaches
    BottomSheetDialogFragment
    scroll constraints.
    • 1
    • 1
  • a

    Alexander Black

    08/13/2021, 9:19 PM
    So this is obviously not done… I’m wondering how I could possibly set new hight measurement of the full screen when drawing the bottom sheet for the first time, so when I move the bars out of the way this bottom sheet will fill the whole view. Any help would be greatly appreciated. 🙂 There’s obviously still some jank in what I’m building.. that will be resolved.
    device-2021-08-13-140858.mp4
    • 1
    • 3
  • d

    dan.the.man

    08/13/2021, 9:41 PM
    Is there an equivalent event to
    onViewAttachedToWindow
    or something I could use to track when something is drawn on screen for impression tracking/user tracking analytics?
    z
    • 2
    • 2
  • f

    Florian

    08/13/2021, 11:17 PM
    How can I add a single Composable at the start of a LazyColumn?
    f
    c
    • 3
    • 5
  • s

    Scott Kruse

    08/13/2021, 11:29 PM
    What is the best way to find out if a composable is visible on screen? Im familiar with getting window rect / running intersection logic for a view, checking View.visible, etc. Is there a different way in compose?
    ➕ 3
    d
    • 2
    • 1
  • b

    Berkeli Alashov

    08/14/2021, 3:59 AM
    https://twitter.com/alashov/status/1426375756603592707?s=19
    👍 5
    👍🏻 1
    c
    • 2
    • 1
  • a

    Adib Faramarzi

    08/14/2021, 6:39 AM
    Is there any specific reason for my
    contentColor
    not working on
    SnackBar
    ? It seems to totally ignore it. Even when providing
    LocalContentColor
    .
    • 1
    • 1
  • r

    Rafiul Islam

    08/14/2021, 8:37 AM
    How can I open navigation drawer from the Right side? I have tried this one but it doesn't work.
    CompositionLocalProvider {
        LocalLayoutDirection provides LayoutDirection.Rtl
        Scaffold(
            drawerContent = {}
        )
    }
    w
    • 2
    • 3
  • r

    Rafiul Islam

    08/14/2021, 8:55 AM
    Is there any way to reduce/remove the default vertical padding of a Textfield? Because sometimes it really needs to be small. I know I can use BasicTextField and customize it as per requirements. But then I have to handle placeholder, leadingIcon everything manually. So I am just asking if there is any solution just to reduce/remove the default vertical padding.
    c
    • 2
    • 2
  • l

    Luis Daivid

    08/14/2021, 10:50 AM
    I want to draw a view like the image below, but I don’t know how. The text is centered, and the length of the dotted line must be filled to fit the screen size.
    c
    • 2
    • 1
  • s

    Shakil Karim

    08/14/2021, 11:09 AM
    Is it possible to
    try catch
    in Composable function? Code in 🧵
    d
    a
    • 3
    • 10
  • p

    Pawel

    08/14/2021, 11:42 AM
    I just tried an app with a LazyColumn on a device and it is really laggy. Its a small example app with hardly any code in it. I would still expect better performance. I think doing a release build helps a bit. Any suggestions of what else could be affecting performance ?
    ➕ 2
    s
    s
    • 3
    • 10
  • f

    Florian

    08/14/2021, 3:58 PM
    Following the instructions for how to integrate bottom navigation with Jetpack Compose, how do I re-instantiate the first screen of a bottom nav item when the same item is clicked twice, and destroy its back stack? https://developer.android.com/jetpack/compose/navigation#bottom-nav Or will that be the default behavior after the launchSingleTop bug has been fixed?
    c
    b
    • 3
    • 5
  • b

    batuhan ardor

    08/14/2021, 4:58 PM
    hi everyone, i've an issue with BoxWithConstraints and the keyboard. I've a userProfile and chat screen, in the chat screen if I the user presses the "close icon" to go back to userProfile, I dismiss the keyboard and call the popBackStack method. If the keyboard is on the screen in chat, userProfile's BoxWithConstraints' maxHeight calculation takes account the keyboard. But if i put a delay for ex. 100ms, then everything is ok. So it seems that the keyboard is dismissing after maxHeight calculation. Any ideas? Thanks.
    • 1
    • 1
  • a

    Ashu

    08/14/2021, 9:09 PM
    Hi Composers So I was using ConstraintLayout in Compose. I created a vertical chain like this:
    createVerticalChain(
        toolbar, text1, text2,
        chainStyle = ChainStyle.Packed
    )
    Now it works all fine but the issue is I don't know how to set margins in this scenario. How do I set top and bottom margin to text1? Also, text1 has following constraints
    constrain(text1) {
        height = Dimension.preferredWrapContent
        width = Dimension.preferredWrapContent
    }
    What I am trying to do here is to set text1 height as wrap content but not bigger than the layout. But if the text is large then the whole text is shown. How do I keep it as wrap content and fill constraint layout but not increase size of constraint layout and ellipsize the remaining text?
    :thread-please: 1
    c
    • 2
    • 3
  • c

    Colton Idle

    08/15/2021, 1:16 AM
    I feel like I'm going crazy, but I can't find docs on how Compose + Hilt + AAC ViewModels can work together to pass arguments into a view model? I'm working on a typical list -> detail app, and I can't figure out how to pass an id from my NavHost to the new DetailScreen.
    😒olved: 1
    f
    s
    +2
    • 5
    • 17
  • a

    Anton Dmytryshyn

    08/15/2021, 2:28 AM
    Has anyone else experienced a BottomSheetScaffold opening when the content in it changes sizes? I have a BottomSheetScaffold which observes a value, and based on the value the ui changes, standard stuff. However, the BottomSheetScaffold keeps opening when the ui changes, yet I would like for it to stay closed.
    c
    a
    • 3
    • 3
  • c

    carbaj0

    08/15/2021, 4:37 AM
    I want to get the cursor in my
    CustomBasicTextField
    (request focus?) 🧵
    • 1
    • 6
  • c

    Colton Idle

    08/15/2021, 4:46 AM
    I have a simple screen that is a Box that has a single button that is algined to the bottom. This works fine. Then I have a root application wrapper composable that has a BottomNavigation and when I navigate to this screen with the box, the bottom navigation should hide. The bottom navigation hides with a 2 second tween. When the tween completes the Screen with the Box jumps down because there is now more area in the screen. I thought the solution was simple. Add
    animateContentSize()
    to the box, but it causes the entire screen to (seemingly) animate upwards. How can I make this Box screen with a bottom button smoother when it's parent expands vertically (i.e. bottomNavigation hides). Thanks!
    • 1
    • 1
  • a

    Ashu

    08/15/2021, 7:54 AM
    Is there not a good way in compose to show a Text component which automatically ellipses whenever there is a visible overflow.?? If not, can you give me any solution to achieve that. My Text component with weight 1 is actually not clipping properly.
    c
    s
    • 3
    • 12
  • p

    PHondogo

    08/15/2021, 9:15 AM
    What is the best way to show validation error description in TextField? There is only isError Boolean parameter.
    d
    c
    • 3
    • 2
  • f

    Florian

    08/15/2021, 10:38 AM
    Can a Column center its children horizontally or do I have to add that alignment to every child separately? Because in the attributes of Column I only see
    verticalArrangement
    .
    k
    • 2
    • 2
  • f

    Florian

    08/15/2021, 12:27 PM
    2 `Text`s with
    maxLines = 1
    placed in a Row. Is there an easy way to let the first Text not push the 2nd one out of the screen if it becomes too big? I could use
    weight
    but that won't work well with different languages and string lengths. I'm looking for something like `RelativeLayout`'s
    endBefore
    .
    u
    e
    • 3
    • 5
Powered by Linen
Title
f

Florian

08/15/2021, 12:27 PM
2 `Text`s with
maxLines = 1
placed in a Row. Is there an easy way to let the first Text not push the 2nd one out of the screen if it becomes too big? I could use
weight
but that won't work well with different languages and string lengths. I'm looking for something like `RelativeLayout`'s
endBefore
.
u

ursus

08/15/2021, 1:24 PM
why would weight 0 not work
f

Florian

08/15/2021, 2:39 PM
weight of 0? And the other one?
e

Erlan Amanatov

08/15/2021, 2:50 PM
use weight = 1f for the first Text, and nothing for second one
u

ursus

08/15/2021, 3:17 PM
im sorry yea 1, 1 means fill the rest
f

Florian

08/15/2021, 4:47 PM
Perfect 😍 Thank you very much guys
View count: 3