Search code examples
androidkotlinandroid-jetpack-composeandroid-datepicker

Jetpack Compose DatePicker is taking empty space even if title and headline are empty


Compose DatePicker is taking empty space even if the title and headline are empty.

It's already published as a bug: https://issuetracker.google.com/issues/267194809

DatePicker:

DatePicker(
    state = rememberDatePickerState(),
    modifier = Modifier.fillMaxWidth(),
    title = {
        // empty
    },
    headline = {
        // empty
    }
)

enter image description here


Solution

  • Hope this solution will remove the empty space.

    1. Just type 'null' in the title and headline;

    2. Then, you need to put 'false' in the showModeToggle parameter.

    Here is the solution:

    DatePicker(
        state = rememberDatePickerState(),
        modifier = Modifier.fillMaxWidth(),
        title = null,
        headline = null,
        showModeToggle = false
    )