Reputation: 38
I used the DatePicker in Jetpack Compose.
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
val datePickerState = rememberDatePickerState(initialSelectedDateMillis = 1578096000000)
DatePicker(state = datePickerState, modifier = Modifier.padding(16.dp), colors = DatePickerDefaults.colors(titleContentColor = Color.Green,headlineContentColor = Color.Red,))}
I could modify colors with color = DatePickerDefaults.colors()
but i did not manage to modify the line with the selected year and month and the arrows to navigate(circled red in the picture). How can I change the color of the elements in this line?
I used color = DatePickerDefaults.colors()
as a property for the DatePicker.
Upvotes: 0
Views: 817
Reputation: 1171
You can't change the colors of that line separately by providing specific colors;
The reason is if you check the source code of the DatePicker from material3 implementation, after some digging, the composable you are searching for is called MonthsNavigation
; here is its signature:
You can find it in the file DatePicker.kt
under the package name androidx.compose.material3
, which is a simple row with some icon buttons and a year picker.
And as you can see, you can't customize anything here by passing parameters such as color, so I think it takes the default colors from your theme colors, consider playing with the colors there!
Or you can copy the code of the DatePicker.kt
file, so you create your own custom date picker, and set the colors yourself!
Upvotes: 0