TIL 220615

박수빈·2022년 6월 15일
0

TIL

목록 보기
24/25

이것이 안드로이드다

2-4. 위젯과 리소스 다루기

res/values/strings.xml

// 하드코딩 대신 파일 만들어 연결
<resources>
  <string name="app_name">Widgets Text Views</string>
</resources>

// layout.xml에서 text 필드에 @string/app_name 으로 연결

색상도 colors.xml 이용

글씨 크기
주로 sp 이용 -> 줌인 해도 깨지지 않아

// dimens.xml
<resources>
  <dimen name="text_dimen">24sp</dimen>
  <dimen name="size_dimen">24dp</dimen>
</resources>
// text는 sp, 일반적 크기는 dp

imeOptions

키보드의 기본 버튼 변경 가능

CompoundButton
checkbox, togglebutton, switch 위젯

ProgressBar

  • 다운로드 등 시간을 예측할 수 없는 경우 -> 원형
    • visibility: GONE 이용해 감춤 (공간 자체를 차지 안함)
  • 정확한 진척도를 표시 -> 바형

안드로이드는 UI 작업을 메인 스레드에서 진행해야 함 (onCreate()는 메인스레드에서 진행됨)

// 새로운 스레드에서 sleep하여 어플 자체가 잠들지 않도록
thread(start=true) {
	Thread.sleep(3000)
    // ui작업은 다시 메인에서
    runOnUiThread{
    	showProgress(false)
    }
}
profile
개발자가 되고 싶은 학부생의 꼼지락 기록

0개의 댓글