티스토리 뷰

2018/04/30 - [Computer/Android&iOS] - ( Android ) Kotlin - 1. 시작하기




뷰의 Visibility 관리


아래와 같이 관리할 수 있다.

if(txv_hello.visibility == View.GONE)
txv_hello.visibility = View.VISIBLE
else if(txv_hello.visibility == View.VISIBLE)
txv_hello.visibility = View.GONE






뷰의 Background Color 변경

txv_hello.setBackgroundColor(Color.parseColor("#ff0000"))


코틀린의 setBackgroundColor 함수에 진입해보면 아래와 같이 JAVA 코드를 볼 수 있다.

/**
* Sets the background color for this view.
* @param color the color of the background
*/
@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) {
if (mBackground instanceof ColorDrawable) {
((ColorDrawable) mBackground.mutate()).setColor(color);
computeOpaqueFlags();
mBackgroundResource = 0;
} else {
setBackground(new ColorDrawable(color));
}
}


이와 같이 Kotlin 코드가 JAVA 로 변환되어 사용된다.

기존 JAVA 를 이용한 개발자들도, Kotlin 을 사용할때 이부분은 위화감 없이 이용할 수 있을 것 같다.







공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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 29 30 31
글 보관함