티스토리 뷰

CalendarView 는 스크롤이 가능한 달력을 보여준다.
탭, 클릭 이벤트로 날짜를 선택 할 수 있으며 원하는 날짜로 달력을 스크롤 하고 찾을 수 있다.
How to
◼ CalendarView code in XML
<CalendarView | |
android:id="@+id/simple_calendarview" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" /> |
◼ CalendarView code in JAVA
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
long selectedDate = calendarView.getDate(); |
Attributes
◼ id
id 는 해당 CalendarView 를 유일하게 식별할 수 있는 속성이다.
<CalendarView | |
android:id="@+id/simple_calendarview" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" /> |
◼ firstDayOfWeek
요일의 시작을 어떤 요일로 할지 설정.
- 1 : 일요일 (default)
- 2 : 월요일
<CalendarView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:firstDayOfWeek="2" /> |

◼ focusedMonthDateColor
현재 선택된 달의 배경색
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
◼ unfocusedMonthDateColor
선택되지 않은 달의 배경색
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
<CalendarView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:focusedMonthDateColor="#00FF00" | |
android:unfocusedMonthDateColor="#FF0000" /> |

◼ maxDate
달력에 표시할 최대 날짜 설정
- mm/dd/yyyy 형식으로 지정 (default : 01/01/2100)
<CalendarView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:maxDate="05/22/2019" /> |

◼ minDate
달력에 표시할 최소 날짜 설정
- mm/dd/yyyy 형식으로 지정 (default : 01/01/1900)
<CalendarView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:minDate="05/22/2019" /> |

◼ selectedDateVericalBar
선택한 날짜의 양쪽에 보일 수직바 설정
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
<CalendarView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:selectedDateVerticalBar="@android:color/black" /> |

◼ selectedWeekBackgrounColor
선택된 주의 배경색상 설정
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
<CalendarView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:selectedWeekBackgroundColor="#0000FF" /> |

◼ showWeekNumber
왼쪽에 주차를 보여줄 것인지 설정 (default = true)
해당 API 는 API level 24 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
<CalendarView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:showWeekNumber="false" /> |

◼ weekNumberColor
주차의 색상지정
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
<CalendarView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:weekNumberColor="#FF0000" /> |

◼ weekSeparatorLineColor
주 구분선 색상 설정
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
<CalendarView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:weekSeparatorLineColor="#FF0000" /> |

Methods
◼ getDate()
현재 선택된 날짜를 millisecond 단위로 반환
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
long selectedDate = calendarView.getDate(); |
◼ setDate(long date)
Millisecond 단위로 날짜 선택
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setDate(1570668133353L); |
◼ setFirstDayOfWeek(int firstDayOfWeek)
요일의 시작을 어떤 요일로 할지 설정.
- 1 : 일요일 (default)
- 2 : 월요일
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setFirstDayOfWeek(2); |
◼ getFirstDayOfWeek()
요일의 시작일 반환
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
int firstDayOfWeek = calendarView.getFirstDayOfWeek(); |
◼ setMaxDate(long maxDate)
달력에 표시할 최대 날짜 설정
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setMaxDate(1558483200000L); // '05/22/2019' |
◼ getMaxDate()
달력에 설정된 최대 날짜 반환
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
long maxDate = calendarView.getMaxDate(); |
◼ setMinDate(long minDate)
달력에 표시할 최소 날짜 설정
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setMinDate(1558483200000L); // '05/22/2019' |
◼ getMinDate()
달력에 설정된 최소 날짜 반환
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
long minDate = calendarView.getMinDate(); |
◼ setShowWeekNumber(boolean showWeekNumber)
왼쪽에 주차를 보여줄 것인지 설정 (default = true)
해당 API 는 API level 24 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setShowWeekNumber(false); |
◼ getShowWeekNumber()
왼쪽에 주차가 보여지는지 확인
해당 API 는 API level 24 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
boolean isShow = calendarView.getShowWeekNumber(); |
◼ getSelectedDateVerticalBar()
수직바에 설정된 drawable 반환
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
Drawable verticalBar = calendarView.getSelectedDateVerticalBar(); |
◼ setSelectedDateVerticalBar(Drawabledrawable) or (int resourceId)
선택한 날짜의 양쪽에 보일 수직바 설정
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setSelectedDateVerticalBar(Color.BLACK); |
◼ setSelectedWeekBackgroundColor(int color)
선택된 주의 배경색상 설정
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setSelectedWeekBackgroundColor(Color.BLACK); |
◼ getSelectedWeekBackgroundColor()
선택된 주의 배경색상 반환
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
int color = calendarView.getSelectedWeekBackgroundColor(); |
◼ setWeekNumberColor(int color)
주차의 색상 설정
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setWeekNumberColor(Color.BLACK); |
◼ getWeekNumberColor()
설정된 주차의 색상 반환
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
int color = calendarView.getWeekNumberColor(); |
◼ setWeekSeparatorLineColor(int color)
주 구분선 색상 설정
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setWeekSeparatorLineColor(Color.BLACK); |
◼ getWeekSeparatorLineColor()
주 구분선 색상 반환
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
int color = calendarView.getWeekSeparatorLineColor(); |
◼ setFocusedMonthDateColor(int color)
선택된 달의 배경색 설정
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setFocusedMonthDateColor(Color.BLACK); |
◼ getFocusedMonthDateColor()
선택된 달의 배경색 반환
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
int color = calendarView.getFocusedMonthDateColor(); |
◼ setUnfocusedMonthDateColor(int color)
선택되지 않은 달의 배경색 설정
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setUnfocusedMonthDateColor(Color.BLACK); |
◼ getUnfocusedMonthDateColor()
선택되지 않은 달의 배경색 반환
해당 API 는 API level 23 까지만 지원한다. (Material style 에서는 지원되지 않는다.)
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
int color = calendarView.getUnfocusedMonthDateColor(); |
◼ setOnDateChangeListener(OnDateChangeListenerlistener)
날짜를 선택하여 변경하게 되면 호출되는 listener
CalendarView calendarView = (CalendarView) findViewById(R.id.simple_calendarview); | |
calendarView.setOnDateChangeListener(new OnDateChangeListener() { | |
@Override | |
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) { | |
Toast.makeText(PhSecondActivity.this, year + "/" + month + "/" + dayOfMonth, Toast.LENGTH_SHORT).show(); | |
} | |
}); |
'Android > UI' 카테고리의 다른 글
Scrollview & HorizontalScrollView (0) | 2019.08.27 |
---|---|
SearchView (0) | 2019.08.27 |
MultiAutoCompleteTextView (0) | 2019.08.27 |
AutoCompleteTextView (0) | 2019.08.27 |
TextClock (0) | 2019.08.27 |
- Total
- Today
- Yesterday
- 안드로이드 인텐트
- onContextItemSelected
- 채굴앱
- bindservice
- Android Service
- Intent
- android flag activity
- 앱테크
- StringUtils
- android intent
- 리워드앱
- task
- 안드로이드 서비스
- 리워드 어플
- android activity flag
- 무료채굴
- mPANDO
- StartService
- M2E
- BroadcastReceiver
- p2e
- RoomDatabase
- WEMIX
- 무료 채굴
- notifyDataSetChanged
- registerForContextMenu
- 앱테크 추천
- task 생성
- onCreateContextMenu
- android task
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |