|
18 | 18 | import com.google.android.material.R; |
19 | 19 |
|
20 | 20 | import android.content.Context; |
| 21 | +import android.content.res.Resources; |
21 | 22 | import android.graphics.Canvas; |
22 | 23 | import android.os.Build.VERSION; |
23 | 24 | import android.os.Build.VERSION_CODES; |
@@ -147,6 +148,7 @@ public View onCreateView( |
147 | 148 | } |
148 | 149 |
|
149 | 150 | View root = themedInflater.inflate(layout, viewGroup, false); |
| 151 | + root.setMinimumHeight(getDialogPickerHeight(requireContext())); |
150 | 152 | GridView daysHeader = root.findViewById(R.id.mtrl_calendar_days_of_week); |
151 | 153 | ViewCompat.setAccessibilityDelegate( |
152 | 154 | daysHeader, |
@@ -456,6 +458,23 @@ public void run() { |
456 | 458 | }); |
457 | 459 | } |
458 | 460 |
|
| 461 | + private static int getDialogPickerHeight(@NonNull Context context) { |
| 462 | + Resources resources = context.getResources(); |
| 463 | + int navigationHeight = |
| 464 | + resources.getDimensionPixelSize(R.dimen.mtrl_calendar_navigation_height) |
| 465 | + + resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_navigation_top_padding) |
| 466 | + + resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_navigation_bottom_padding); |
| 467 | + int daysOfWeekHeight = |
| 468 | + resources.getDimensionPixelSize(R.dimen.mtrl_calendar_days_of_week_height); |
| 469 | + int calendarHeight = |
| 470 | + MonthAdapter.MAXIMUM_WEEKS |
| 471 | + * resources.getDimensionPixelSize(R.dimen.mtrl_calendar_day_height) |
| 472 | + + (MonthAdapter.MAXIMUM_WEEKS - 1) |
| 473 | + * resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_month_vertical_padding); |
| 474 | + int calendarPadding = resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_bottom_padding); |
| 475 | + return navigationHeight + daysOfWeekHeight + calendarHeight + calendarPadding; |
| 476 | + } |
| 477 | + |
459 | 478 | @NonNull |
460 | 479 | LinearLayoutManager getLayoutManager() { |
461 | 480 | return (LinearLayoutManager) recyclerView.getLayoutManager(); |
|
0 commit comments