개발새발 로그

안드로이드 스튜디오 고급위젯 간단하게 다루기 본문

안드로이드

안드로이드 스튜디오 고급위젯 간단하게 다루기

이즈흐 2022. 5. 20. 02:07

오늘은 안드로이드 스튜디오에서 제공되는 고급 위젯을 간단하게 배워보겠습니다!

 

 

 

아날로그시계와 디지털시계

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical">

    <AnalogClock
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    <DigitalClock
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"/>

</LinearLayout>

실행 화면

 

 

크로노미터(Chronometer)

  • 타이머 형식의 위젯
  • 일반적으로 시간을 측정할 때 많이 사용함
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical">

    <Chronometer
        android:id="@+id/chronometer1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:format="시간 측정: %s"
        android:gravity="center"
        android:textSize="30dp"
        />


</LinearLayout>

실행 화면

 

 

 

타임 피커,캘린더뷰

  • 타임 피커(TimePicker) : 시간을 표시, 조절
  • 데이트 피커(DatePicker)와 캘린더뷰(CalendarView) : 날짜를 표시, 조절
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical">

    <TimePicker
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:timePickerMode="spinner"/>
    <DatePicker
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:datePickerMode="spinner"/>
    
</LinearLayout>

실행 화면

 

728x90
반응형
LIST