android - 如何减小 CalendarView 的大小?

标签 android calendarview

我可以知道如何在 Android 中调整 CalendarView 的大小吗? CalendarView 占据了一半以上的屏幕。 我希望把它变小,大概占屏幕的 40%。谢谢。

我手机默认的CalendarView大小,占了一半多

CalendarView

我当前的 XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ada.landing.MainActivity">

<CalendarView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/calendarView"
    android:firstDayOfWeek="2"/></RelativeLayout>

我尝试了另一种方式来定义CalendarView,但是整体高度降低了但并没有按比例缩小:

CalendarView

<CalendarView
            android:layout_width="500dp"
            android:layout_height="200dp"
            android:id="@+id/calendarView"
            android:firstDayOfWeek="2" />

最佳答案

我认为 CalendarView 不能(真的)调整大小,因为 Android 会调整此 View 的大小以允许用户在使用此 View 时获得良好的体验。 我认为公共(public)大小是在使用 DatePickerDialog 时。 DatePickerDialog

CalendarView 需要最小高度和宽度。

如果你真的想调整你的 calendarView 的大小,也许可以尝试以编程方式调整(或缩放)它的大小:

float 比例因子 = 0.5f;//缩小到一半大小 view.setScaleX(比例因子); view.setScaleY(scalingFactor);

关于android - 如何减小 CalendarView 的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39558099/

相关文章:

android - 实现 'com.github.prolificinteractive:material-calendarview:2.0' 无法解析

Android CalendarView 减慢布局

android - 'react-native run-android' 正在 android 设备中加载旧包

java - 从 firebase 读取数据没有 setter 字段错误 Firebase

android是否可以在后台运行服务直到我们停止它

java - 找不到 Android CalendarView 类

android - 如何在 Android 中迁移 Realm

Android 数据库设计,使用 SQLite 或直接使用 mySQL 和 JSON

Android 日历标题在 material-calendarview 中显示错误的月份

Android 自定义日历 View 禁用特定日期