본문 바로가기
728x90

안드로이드7

ViewPager - setOffscreenPageLimit(Fragment 의 생명주기 관리) setOffscreenPageLimit() 을 이용해 현재 페이지를 기준으로 좌, 우의 프래그먼트의 생명주기를 관리할 수 있다. 만약 페이지가 총 5개일 때를 예를 들면 Exam setOffscreenPageLimit(1) Page 1 Page 2 Page 3(현재 페이지) Page 4 Page 5 DEAD LIVE LIVE LIVE DEAD Page 1 Page 2(현재 페이지) Page 3 Page 4 Page 5 LIVE LIVE LIVE DEAD DEAD Page 1 (현재 페이지) Page 2 Page 3 Page 4 Page 5 LIVE LIVE DEAD DEAD DEAD setOffscreenPageLimit(2) Page 1(현재 페이지) Page 2 Page 3 Page 4 Page 5 .. 2020. 12. 13.
[Android] Hilt 의존성 주입(DI) gradle 버전, 각 어노테이션 설명 gradle.build(project) buildscript { ext.kotlin_version = '1.3.72' ext.hilt_version = '2.28-alpha' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:4.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version" } } gradle.build(module) . . . apply plugin: 'kotlin-kapt' .. 2020. 12. 11.
[Android] menu 를 가진 layout 의 item 색상 변경 BottomNavigationView 혹은 NavigationView 등 menu 의 아이템을 가진 Layout 들의 아이템 색상을 변경할 수 있다. app:itemIconTint - 아이템의 아이콘 색상 지정 - xml 을 통해 check/uncheck 상태에 따라 색상을 나눌 수 있다. app:itemTextColor - 아이템의 글자 색상 지정 - xml 을 통해 check/uncheck 상태에 따라 색상을 나눌 수 있다. Exam 아래의 xml 을 지정해주면 check/uncheck 상태에 따라 색상을 나눌 수 있다. @color/colorCheck 2020. 12. 10.
[Context] Fragment 에서 context 와 requireContext context /** * Return the {@link Context} this fragment is currently associated with. * * @see #requireContext() */ @Nullable public Context getContext() { return mHost == null ? null : mHost.getContext(); } requireContext /** * Return the {@link Context} this fragment is currently associated with. * * @throws IllegalStateException if not currently associated with a context. * @see #getContext() .. 2020. 12. 10.
728x90