简体   繁体   English

在 Android 中更改 MaterialDatePicker 的宽度和高度

[英]Change width and height of MaterialDatePicker in Android

Users of my app use 10", 15", and 22" android tablets. I'm employing the MaterialDatePicker control to allow them to choose dates in an activity. I'm getting complaints that the numbers in the calendar are too tiny and hard to hit in just the right way. I'd like to make the entire control 30% larger. I was able to set the theme upon creating the control:我的应用程序的用户使用 10"、15" 和 22" android 平板电脑。我使用 MaterialDatePicker 控件来允许他们在活动中选择日期。我收到抱怨日历中的数字太小太硬以正确的方式击中。我想让整个控件大 30%。我能够在创建控件时设置主题:

            val builder = MaterialDatePicker.Builder.datePicker()
            builder.setTitleText(R.string.label_end_date)
            builder.setTheme(R.style.MaterialDatePickerStyle)

I was able to increase text size:我能够增加文本大小:

<style name="MaterialDatePickerStyle" parent="ThemeOverlay.MaterialComponents.MaterialCalendar">
    <item name="android:textSize">18sp</item>
</style>

android:Width has no effect, scaleX/scaleY aren't doing the job either. android:Width 没有效果, scaleX/scaleY 也不起作用。

You can't change android:textSize in this way since it is not an attribute theme.您不能以这种方式更改android:textSize ,因为它不是属性主题。
To change the dimension of the text used in the days you can use something like:要更改过去使用的文本的尺寸,您可以使用以下内容:

   <style name="MaterialDatePickerStyle" parent="ThemeOverlay.MaterialComponents.MaterialCalendar">
        <item name="materialCalendarDay">@style/Widget.App.MaterialCalendar.DayTextView</item>
    </style>

    <style name="Widget.App.MaterialCalendar.DayTextView" parent="Widget.MaterialComponents.MaterialCalendar.DayTextView">
        <item name="android:textAppearance">?attr/textAppearanceBody1</item>
    </style>

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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