본문 바로가기

728x90

Android

(19)
ImageView 의 ContentDescription 설정에 대해서... - xml 에서 ImageView 사용 시 아래와 같은 warning 이 발생한다. - ImageView 의 경우 텍스트가 없는 경우가 거의 대부분이라 xml 구성 시 최신 Android Studio 에 "contentDescription" 속성을 설정하도록 Warning 을 제공한다. - 해당 설정을 통해서 시각 장애가 있는 유저에게 ImageView 에 대한 설명을 제공한다.
ObjectAnimator - Android Document : https://developer.android.com/guide/topics/graphics/prop-animation?hl=ko ValueAnimator 사용 시 addUpdateListener 에 View 를 등록하여 애니메이션을 처리 함 ObjectAnimator : ValueAnimator 의 하위 클래스로 addUpdateListener 없이 View 의 애니메이션 처리가 가능 함 - ObjectAnimator 관련 사용가능한 함수 및 속성 translationY, translationX : 가로/세로 이동 시 사용 alpha : opacity 를 이용한 애니메이션 적용 시 사용 duration : 애니메이션 재생 시간 interpolator : 애니메이션 ..
FullScreen Theme 에서의 AppCompat Widget 에러 처리 현상 AppCompatActivity 를 상속받은 Activity 에서 FullScreen 속성의 Theme 을 설정하고 xml 에서 AppCompat Widget 을 사용할 경우 아래와 같이 ThemeUtils 에서 에러로그가 발생한다. 원인 AppCompatActivity 는 아래와 같은 FullScreen Theme 이 아닌 Theme.AppCompat 를 사용하고 AppCompatWidget 을 적용해야 하기 때문이다. 해결 방법 1. AppCompatActivity 가 아닌 최상위 Class 인 Activity 를 직접 상속한다. 2. Theme.AppCompat Theme 을 적용하고 FullScreen 속성은 코드 상에서 Activity ViewCreate 시점에 적용한다. 3. FullSc..
RxKotlin 의존성 추가 1. 최신 버전 확인 (2021.03.08 기준 : 2.4.0) mvnrepository.com/artifact/io.reactivex.rxjava2/rxkotlin Maven Repository: io.reactivex.rxjava2 » rxkotlin RxJava bindings for Kotlin VersionRepositoryUsagesDate2.4.x2.4.0Central83Jul, 20192.4.0-RC3Central3Jul, 20192.4.0-beta.1Central2Jun, 20192.3.x2.3.0Central88Aug, 20182.2.x2.2.0Central65Nov, 20172.1.x2.1.0Central28Jun, 20172.0.x2.0.3Central2May, 20172.0.2Ce..
Android Kotlin Extensions 적용 1. 용도 확장 함수 확장 프로그램 속성 람다 이름이 지정된 매개변수 매개변수 기본값 코루틴 2. 적용 방법 android build.gragle 에 plugin 추가
안드로이드 스튜디오 Kotlin Memory Leak Warning("StaticFieldLeak") - Android Studio (1.4 이상 plugin 설치) 에서 Kotlin Object Class 에 대해서 field 에 Context 를 선언할 경우 Warning 에러가 발생한다. - Error Message Do not place Android context classes in static fields (static reference to AppContext which has field activityContext pointing to Context); this is a memory leak - 해결 방법 1. @SuppressLint("StaticFieldLeak") Annotation 추가한다. 2. context 를 Object class 에 넘겨주는 대신 Application Con..
TextView MultiLine 처리 - TextView 에 긴 줄의 Text 를 처리할 때 일반적으로 안드로이드 고정된 Width 의 TextView 에서 자동으로 글자 수에 따라 다음 줄로 처리되어 있다. 그리고 끝을 "..." 으로 끝내고 싶을 때에는 아래의 속성을 추가한다. android:ellipsize="end" - MultiLine TextView 왼쪽에 다른 아이템이 있을 경우에는 가변적으로 TextView Width 처리를 한다. 1. 가변 처리를 하지 않을 경우 2. 가변 처리를 할 경우 - 가변 처리 방법 코드 상에서 아래와 같이 조건에 따라 가변 처리를 수행한다.
Subroutine override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val sum = (0..10).toMutableList().sum() result_text.text = "Result : $sum" // sum() 연산이 끝난 후 결과 return } // Subroutine private fun MutableList.sum(): Int = this.sumBy { it }