코틀린 6-2, 3 뷰

hong030·2022년 1월 30일
0
  • 뷰 : 뷰 그룹(linear layout, relative layout 등) + 텍스트 뷰, 이미지 뷰, 등...

여기서 뷰 그룹이란 여러 뷰 객체를 담아 한꺼번에 제어할 목적.
레이아웃은 중첩 가능하다.(이런 중첩 패턴을 composite pattern 혹은 document object model이라 한다.

  • 뷰를 xml에서 구현할 때
    0) 레이아웃 android:orientation="vertical"
    0) 레이아웃 색 android:background="#ff0000"
    1) 아이디 android:id = "@+id/t1"
    이러면 kt 코드에서 val tv1:TextView = findViewById(R.id.t1) 해서 사용 가능.
    val tv1=findViewById<TextView//>(R.id.t1) 으로도 할 수 있음.

    2) 크기 android:layout_width = "wrap_content"
    3) 버튼 색 android:backgroundTint="#ff0000"
    android:layout_height = "match_content"
    3) 가시성 android:visibility = "invisible" 안보이되 공간 차지
    android:visibility="gone" 안보이고 공간도 차지 안함.
        

<기본적인 뷰>

  • text view
    1) 링크 걸기 android:text = "http://naver.com, 010-1111-1111, hello@naver.com" android:autoLink="web|phone|email"
    2) 최대 줄 출력 android:maxLines = "3" 3줄까지 출력.
    3) ... 줄임표 android:ellipsize="middle" 중간 ...로 생략

  • image view
    1) android:src = "@drawable/test1"
    2) 크기 android:adjustViewBounds="true"
    android:maxWidth="100dp"
    android:maxHeight="100dp"

  • 버튼, 체크박스, 라디오 버튼
    라디오버튼은 특이하게 <RadioGroup 으로 묶어야 함.

  • 에디트 텍스트: 사용자가 글 입력하는 뷰
    1) android:inputType = "phone" 키보드가 phone 입력만 가능하게 강제.

profile
자바 주력, 프론트 공부 중인 초보 개발자. / https://github.com/hongjaewonP

0개의 댓글