简体   繁体   中英

Datepicker in spinner mode Jetpack compose

is there any ways to inflate datepicker in spinner mode? When I use AndroidView I cannot use xml view.I tried to define attribute set but still couldnt manage to get it. When I define in style, I cannot scroll properly.

    <style name="DatePickerSpinnerStyle" parent="@android:style/Widget.DeviceDefault.DatePicker">
        <item name="colorControlNormal">@color/purple_200</item>
        <item name="android:textColorPrimary">@color/purple_700</item>
        <item name="android:datePickerMode">spinner</item>
    </style>

        val customView = DatePicker(ContextAmbient.current, null, R.style.NdDatePickerSpinnerStyle)
        customView.spinnersShown = true //deprecated
        customView.calendarViewShown = false //deprecated
        AndroidView(
            modifier = Modifier.fillMaxSize().background(color = Color.White)
                .align(Alignment.CenterHorizontally),
            viewBlock = { customView })

try use R.style.Theme_Material_Dialog Seems work for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM