발전을 위한 기록

<안드로이드스튜디오> 안드로이드 - 캘린더 뷰를 이용해 날짜 확인 본문

프로그래밍/안드로이드

<안드로이드스튜디오> 안드로이드 - 캘린더 뷰를 이용해 날짜 확인

릴릴2 2021. 7. 21. 00:45

개인 기록용으로 자세한 설명은 없다.

안드로이드 스튜디오 안에 있는 캘린더 뷰를 이용하여 간단한 달력 제작

1. layout구성 

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

    <CalendarView
        android:id="@+id/calendarView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:maxDate="12/31/2090" //달력 최대
        android:minDate="01/01/1990" //달력 최소
        />


        <TextView //날짜
            android:background="@color/black"
            android:id="@+id/textView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:gravity="center"
            android:text="날짜"
            android:textColor="@android:color/white"
            android:textSize="25sp" />


    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerMemo"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:overScrollMode="never"
        android:scrollbarFadeDuration="0"
        android:scrollbarSize="5dp"
        android:scrollbarThumbVertical="@android:color/darker_gray"
        android:scrollbars="vertical" />

</LinearLayout>

 

위 코드 작성시 결과

 

2. MainActivity 코드

실행결과

728x90