TextView, ImageView, Button, EditText
[ TextView ]
화면에 텍스트를 출력하는 위젯 (선택적으로 수정 가능)
TextView의 상속 계층도
java.lang.Object
└─ android.view.View
└─android.widget.TextView
TextView의 하위 클래스들
Button, CheckedTextView, Chronometer, DigitalClock, EditText
TextView 속성
text - 텍스트 뷰의 가장 중요한 속성. 출력할 문자열을 지정
android:text="Hello, everyone."
textColor - 문자열의 색상을 지정. #rgb, #argb, #rrggbb, #aarrggbb
android:textColor="#FF00FF"
textSize - 텍스트의 폰트 크기를 지정. sp, dp, px, in, mm등의 단위와 같이 지정해야 한다.
android:textSize="20sp"
textStyle - 폰트의 속성을 지정. normal, bold, italic
typeface - 글꼴의 모양을 지정. normal, sans, serif, monospace
android:typeface="serif"
width, height - 텍스트 뷰의 폭과 높이. 크기값과 단위를 같이 지정.
singleline
- 텍스트가 위젯의 폭보다 더 길 대 강제로 한 줄에 출력한다.
- 위젯의 폭을 넘는 문자열은 오른쪽 끝이 잘리되 줄 끝에 ... 생략 표시가 나타난다.
[ ImageView ]
아이콘이나 비트맵을 출력하는 위젯
ImageView의 상속 계층도
java.lang.Object
└─ android.view.View
└─ android.widget.ImageView
버튼의 하위 클래스들
ImageButton
ImageView 속성
src
- 출력할 이미지를 지정하는 가장 중요한 속성 (이 속성에 값을 대입하지 않으면 아무것도 보이지 않는다.)
- @drawable/ID 형식으로 미리 준비해 놓은 이미지를 출력한다.
android:src="@drawable/pride"
maxHeight, maxWidth - 이미지가 출력될 최대 크기를 지정
android:maxHeight="100px", android:maxWidth="100px"
adjustViewBounds - 이미지의 종횡비를 맞추기 위해 이미지 뷰의 크기를 적당히 조정할 것인가를 지정
android:adjustViewBounds="true"
cropToPadding - 위젯의 주어진 여백에 맞추기 위해 이미지의 일부를 잘라낸다.
tint - 이미지에 색조를 입힌다.
scaleType
- 이미지의 원래 크기와 다르게 출력할 대 적용할 확대, 축소 방식 지정.
- matrix, fitXY, center, centerCrop, centerInside등
[ Button ]
사용자가 클릭하여 명령을 내릴 수 있는 위젯
Button의 상속 계층도
└─ android.view.View
└─android.widget.TextView
└─ android.widget.Button
버튼의 하위 클래스들
CompoundButton, CheckBox, Chronometer, DigitalClock, EditText
[ EditText ]
문자열을 입력받는 위젯
EditText의 상속 계층도
└─ android.view.View
└─android.widget.TextView
└─ android.widget.EditText
버튼의 하위 클래스들
AutoCompleteTextView
원본 : 안드로이드 프로그래밍 정복