fix: 달력 5행 고정높이, 6행 스크롤 지원

- 5행: RecyclerView 높이를 행 수에 맞게 고정, 스크롤 없음
- 6행: RecyclerView 높이를 6행으로 고정, 스크롤 활성화
- 아이템 높이를 화면 너비 기준 정사각형으로 통일

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-03-12 23:18:12 +09:00
parent 819495323e
commit 7835d0ab65
3 changed files with 20 additions and 10 deletions

View File

@@ -52,15 +52,10 @@ class CalendarAdapter(
val item = days[position]
val context = holder.itemView.context
// Dynamically adjust item height based on row count (5 or 6 rows)
// Fixed item height - square cells based on screen width
val displayMetrics = context.resources.displayMetrics
val screenWidth = displayMetrics.widthPixels
val itemWidth = screenWidth / 7 // Each cell width
val itemHeight = if (rowCount == 5) {
(itemWidth * 1.2).toInt() // Taller items for 5 rows to fill space
} else {
itemWidth // Square items for 6 rows
}
val itemHeight = screenWidth / 7
val layoutParams = holder.itemView.layoutParams
layoutParams.height = itemHeight
@@ -74,7 +69,6 @@ class CalendarAdapter(
holder.itemView.visibility = View.VISIBLE
// Day Number
holder.dayNumber.text = item.date.dayOfMonth.toString()
// Holiday / Weekend logic
val isSunday = item.date.dayOfWeek == java.time.DayOfWeek.SUNDAY

View File

@@ -320,7 +320,22 @@ class MainActivity : AppCompatActivity() {
}
}, binding.cbShowHolidays.isChecked, rowCount)
binding.calendarGrid.adapter = adapter
binding.calendarGrid.adapter = adapter
// Set RecyclerView height based on row count
// 5 rows: fixed height to fill space, no scroll
// 6 rows: max height (5 rows worth), enable scroll
val displayMetrics = resources.displayMetrics
val screenWidth = displayMetrics.widthPixels
val cellHeight = screenWidth / 7 // Square cells
val recyclerViewHeight = cellHeight * rowCount
val layoutParams = binding.calendarGrid.layoutParams
layoutParams.height = recyclerViewHeight
binding.calendarGrid.layoutParams = layoutParams
// Disable scroll for 5 rows, enable for 6 rows
binding.calendarGrid.isNestedScrollingEnabled = rowCount > 5
binding.monthTitle.text = currentViewMonth.format(DateTimeFormatter.ofPattern("yyyy년 MM월"))
// Update Header Status Text with Permission Warning if needed

View File

@@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dayRoot"
android:layout_width="match_parent"
android:layout_height="85dp"
android:layout_height="wrap_content"
android:minHeight="72dp"
android:background="@drawable/bg_grid_cell_v4">
<!-- Day Number (top-left) -->