Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Compose
- pandas
- 백준
- Coroutines
- Hilt
- TEST
- ProGuard
- MyVoca
- Coroutine
- androidStudio
- boj
- 암호학
- relay
- 코루틴
- 쿠링
- AWS
- Kotlin
- Codeforces
- textfield
- Rxjava
- 프로그래머스
- Python
- GitHub
- 코드포스
- MiTweet
- livedata
- architecture
- Gradle
- activity
- android
Archives
- Today
- Total
이동식 저장소
Fragment에서 View의 크기를 알고 싶을 때 본문
한줄요약: ``onCreateView()``에서 ``binding.root.post``를 호출하고, 그 안에서 ``measuredHeight``/``measuredWidth``에 접근할 수 있다.
private var _binding: FragmentTestBinding? = null
private val binding
get() = _binding!!
override fun onCreateView() {
_binding = FragmentTestBinding.inflate(...)
binding.root.post {
val size = root.measuredHeight
// ...
}
}
Android get layout height and width in a fragment
I am working on a fragment and I want to get the dimension of a layout contained in the xml fragment layout. When I try the code RelativeLayout myLayout = view.findViewById(R.id.myLayout); myLayout.
stackoverflow.com
'Primary > Android' 카테고리의 다른 글
Android에서 Vector Drawable 추가하기 (0) | 2021.06.29 |
---|---|
[Android] WorkManager 정리 (0) | 2021.05.28 |
Widget에서 Room 데이터베이스에 접근하는 방법 (0) | 2021.05.06 |
[Hilt] 2. Dependency Injection with Hilt (5) | 2021.04.29 |
[Hilt] 1. 의존성 주입이란? (1) | 2021.04.29 |
Comments