일반적인 방법으로 clickable을 설정하면 나만 그런지 모르겠지만, 필자의 경우에는 clickable이 적용되지 않았다. TextField의 focus 여부를 가져오는 방법으로 clickable을 대체하였다. modifier = Modifier .wrapContentWidth() .focusRequester(FocusRequester()) .onFocusChanged { if (it.isFocused) { onSearcherChanged(field) } } 위 코드처럼 하면 된다.
Collection.distinct() 를 이용하면 된다.
http://airbnb.io/lottie/#/android-compose Lottie Docs airbnb.io 우선 공식 문서대로 진행한다. 하지만 이때 LottieAnimation() 사용 부분에서 오류가 발생한다. 다음과 같이 직접 함수에 dsl을 적용(?)시켜서 하면 된다. LottieAnimation( spec = animationSpec, animationState = animationState, modifier = Modifier.fillMaxHeight() )
https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary#SwipeToDismiss(androidx.compose.material.DismissState,%20androidx.compose.ui.Modifier,%20kotlin.collections.Set,%20kotlin.Function1,%20kotlin.Function1,%20kotlin.Function1) androidx.compose.material | Android 개발자 | Android Developers androidx.wear.watchface.complications.rendering developer.android.com 공식 문서..
Glide이나 Coil을 이용하여 remember~~Painter로 URL에서 이미지를 불러오면 이상하게 이미지가 검은색으로만 보인다. 아무리 검색을 해도 도저히 해결법을 못 찾아서 필자는 다음과 같이 해결했다. 그냥 일반 Glide을 적용해주고 @Composable fun Image(modifier: Modifier, src: Any) { val context = LocalContext.current AndroidView(factory = { ImageView(context) }, modifier = modifier) { GlideApp.with(context).load(src).into(it) } } 처럼 따로 함수를 만들어서 Image(modifier = Modifier.size(100.dp), s..
바로 본문으로 들어가자면, Arrangement는 중심축을, Alignment는 중심축의 반대 축을 의미한다. 즉, Row의 중심축은 가로축 이므로 horizontalArrangement 이 되고 Column의 중심축은 세로축 이므로 verticalArrangement가 된다. 반대로 Alignment도 보면, Alignment는 중심축의 반대 축 이기 때문에 Row의 경우에는 세로축이, Column의 경우에는 가로축이 해당된다. 추가로 Arrangement.SpaceEvenly, Arrangement.SpaceAround, Arrangement.SpaceBetween 이 3개가 각각 무슨 역할인지 유난히 헷갈린다. 이것들에 대해 설명하겠다. Arrangement.SpaceBetween: 첫 번째 항목을..
androidx.compose.runtime:runtime-livedata:${Versions.Compose.Version} 위 의존성 추가 후, private val _materialCounts: HashMap = hashMapOf() private fun _getMaterialCount(material: String): MutableLiveData { val value = _materialCounts[material] if (value == null) _materialCounts[material] = MutableLiveData(0) return _materialCounts[material]!! } fun getMaterialCount(material: String): LiveData { return..
우선 이 것들에 대해 알려면 compose의 작동 방식부터 알아야 합니다. 초기 컴포지션: 처음 컴포저블을 실행하여 컴포지션을 만듭니다. 리컴포지션: 데이터가 변경될 때 컴포지션을 업데이트하기 위해 컴포저블을 다시 실행하는 것을 말합니다. (출처: developer.android.com/jetpack/compose/state?hl=ko) 이때 리컴포지션이 되면서 기존에 컴포지션 됐던 데이터들이 삭제되는데, 이때 remember로 지정된 값들이 메모리에 남아있다가 리컴포지션이 될 때 돌아옵니다. 이렇게 해서 기존 데이터들이 리컴포지션 될 때도 유지될 수 있는 것입니다. 리컴포지션은 State값이 바뀔 때 이루어집니다. State는 Compose에서 관찰 가능한 유형입니다. 이제 rememberSaveabl..