본문 바로가기
반응형

compose9

[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.
[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.
[Android] Compose Dialog Full Screen (Full Width Screen) Compose 에서 Dialog 를 사용하면 아래와 같이 양 옆에 기본 마진이 생긴다. 하지만 디자인에 따라 양옆의 마진이없어야 하는 경우가 발생한다. 양옆의 마진을 없애기 위해선 아래와 같이 properties = DialogProperties(usePlatformDefaultWidth = false) 해주면 된다. Dialog( onDismissRequest = onDismissRequest, properties = DialogProperties(usePlatformDefaultWidth = false) ) { .......... 내용 ........ } 아래와 같이 양 옆의 마진이 없어진 채로 나오게 된다. 예제 코드 @Composable fun ListDialog( items: List, text.. 2023. 5. 10.
반응형