코틀린-하위버전 호환성 에러무시

@RequiresApi(Build.VERSION_CODES.R) // 하위버전에서 지원하지 않는 API는 개발자가 알아서 하겠다.

코틀린-버튼컬러 액션

리소스xml 파일 생성 후 아래내용 참고(res/color/btn가정) <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:color=”#ffff0000″ android:state_pressed=”true”/> <item android:color=”#ff0000ff” android:state_focused=”true”/> <item android:color=”#ff000000″ /> </selector> 액티비티 xml에서 아래내용 참고 <Button android:layout_width=”match_parent” android:layout_height=”match_parent” android:text=”Click” android:textColor=”@color/btn”/>

코틀린-GridLayout 가운데 정렬

GridLayout은 android:layout_gravity=”center” 설정하면 쉽게 가운데 정렬이 가능하다. 문제 GridLayout 내부에 추가한 뷰들이 가운데 정렬이 안되어 이것저것 찾아보다 android:gravity=”center” android:layout_width=”0dp” android:layout_columnWeight=”1″ 를 추가하여 해결하였다.  핵심은 요놈 android:layout_columnWeight=”1″ 설정함으로써 여백확장을 하면 된다. <GridLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:columnCount=”3″ android:orientation=”horizontal” android:layout_gravity=”center”> <TextView android:gravity=”center” android:layout_width=”0dp” android:layout_columnWeight=”1″ android:layout_height=”wrap_content” android:paddingLeft=”20dp” android:paddingRight=”20dp” android:text=”1″ android:textSize=”80sp” android:textStyle=”bold” /> <TextView android:gravity=”center” android:layout_width=”0dp” android:layout_columnWeight=”1″ android:layout_height=”wrap_content” android:text=”2″ android:textSize=”80sp” android:textStyle=”bold” …
코틀린-GridLayout 가운데 정렬 더보기

코틀린-SplashActivity-빌드 후 ADT에서 앱이 실행 안되는 경우

SplashActivity를 이용하여 앱을 하나 만들었는데 빌드 후 앱이 실행되지 않는다. 당연히 빌드 에러는 하나도 발생하지 않았다. 물리적 안드로이드폰을 연결하면 자동실행은 아니더라고 설치까지는 되는데 수동실행해야한다. ADT는 앱 아이콘만 생기고 설치가 안되었다고 실행도 안된다. 해결방법은 간단하다. AndroidManifest.xml에서 <activity android:name=”.SplashActivity” android:exported=”flase”> 을 <activity android:name=”.SplashActivity” android:exported=”true”> 로 변경하면 된다.