본문 바로가기
반응형

Android/Kotlin14

[Android] Compose Auto Scroll pager 자동으로 Scroll 되고 사용자가 Scroll 할 수 있는 Pager 가 필요한 경우가 있다. 얼마전까지 Accompanist 에 있었지만 deprecated 되어서 구현했다. 중요한 것은 pagerState의 현재 page 값을 받아오는 state다. pagerState.settledPage The page that is currently "settled". This is an animation/gesture unaware page in the sense that it will not be updated while the pages are being scrolled, but rather when the animation/scroll settles. Please refer to the sample to.. 2023. 7. 24.
[Android] Compose 다중 이벤트 방지 Compose 를 사용하다보면 버튼을 클릭했을때 중복 이벤트가 발생하는 것을 막아야 할 때가 있다. 처음 이벤트만 통과시키고 특정 시간동안 이벤트를 무시한다. 처음 이벤트가 발생 후 다른 이벤트가 연속적으로 발생하면 연속적으로 이벤트가 들어오지 않을때까지 이벤트를 무시한다. package com.danchoo.utils.common fun (() -> Unit).throttleFirst(time: Long = 200L) { MultipleEventPrevention.processEvent(time) { this() } } fun ((T) -> Unit).throttleFirst(value: T, time: Long = 200L) { MultipleEventPrevention.processEvent(tim.. 2023. 7. 24.
Caused by: org.gradle.api.GradleException: 'compileDebugJavaWithJavac' task (current target is 1.8) and 'kaptGenerateStubsDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version. Android Studio 를 업데이트 하고 Gradle 업데이트를 하니 아래와 같은 에러가 발생했다. Caused by: org.gradle.api.GradleException: 'compileDebugJavaWithJavac' task (current target is 1.8) and 'kaptGenerateStubsDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version. compileOptions에서 JavaVersion 을 업데이트 하면 된다. Gradle 파일에 따라 아래와 같이 수정하면 된다. compileOptions.run { sourceCompatibilit.. 2023. 6. 16.
[Compose] Compose Image center crop not working 이미지를 배경으로 설정 하려고 했지만 이미지 사이즈가 변경 되지도 않고 Center Crop 속성이 적용되지 않는 버그가 있었다. 재현되는 버전 Compose Compiler Version : 1.4.4 Compose Version : 1.4.0 배경으로는 설정을 해야 하고 이미지의 height 가 Component 보다 커지는 이상한? 버그가 있었다. ConstraintLayout 도 사용해봤고 BoxWithConstraint 도 사용해 봤고 IntrinsicSize.Min 으로도 해봤고.... 다 안되었다. 마지막으로 찾은 방법이 Contents 의 height 를 계산하여 height 를 맞춰주는 것!!! 예시의 Contents 는 Colum 으로 구성이 되어있다. Colum 의 높이를 구한다음 i.. 2023. 5. 15.
반응형