对于某些较小的屏幕尺寸,CalendarView 不显示一个月中的所有日期
CalendarView not displaying all days in month for some smaller screen size
这是我的日历视图
<CalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_above="@+id/tableLayout"
android:layout_alignParentTop="true" />
在此下方我有 3 个按钮,下面给出 xml
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="@+id/tableLayout"
android:padding="5dp" android:stretchColumns="0"
android:textAlignment="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/tableRow1">
<Button
android:id="@+id/trackAttendance"
android:layout_height="wrap_content"
android:text="Track Class Attendance"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_width="50dp"
android:textColor="#ffffff"
android:textSize="15dp"
android:background="@drawable/mybuttons"> </Button>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/tableRow2">
<Button
android:id="@+id/trackSessions"
android:layout_height="wrap_content"
android:text="Track Study Sessions"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_width="50dp"
android:textColor="#ffffff"
android:textSize="15dp"
android:background="@drawable/mybuttons"> </Button>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/tableRow3">
<Button
android:id="@+id/trackActivities"
android:layout_height="wrap_content"
android:text="Track Class Activities"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_width="50dp"
android:textColor="#ffffff"
android:textSize="15dp"
android:background="@drawable/mybuttons"> </Button>
</TableRow>
</TableLayout>
当我运行在一些屏幕尺寸小于4.5"的手机上时,我无法在日历视图中查看一个月的所有日期。显示如下
在不使用 stock google calendarview 的情况下,是否有解决此问题的方法。
提前致谢
这正在发生,因为您的按钮的高度是 wrap_content
..
因此按钮与您的日历视图重叠
要么尝试使用 ScrollView
参考 This 创建布局。
或
将 LinearLayout
与 weightsum
和 layout_Weight
结合使用。参考 This .
这是我的日历视图
<CalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_above="@+id/tableLayout"
android:layout_alignParentTop="true" />
在此下方我有 3 个按钮,下面给出 xml
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="@+id/tableLayout"
android:padding="5dp" android:stretchColumns="0"
android:textAlignment="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/tableRow1">
<Button
android:id="@+id/trackAttendance"
android:layout_height="wrap_content"
android:text="Track Class Attendance"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_width="50dp"
android:textColor="#ffffff"
android:textSize="15dp"
android:background="@drawable/mybuttons"> </Button>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/tableRow2">
<Button
android:id="@+id/trackSessions"
android:layout_height="wrap_content"
android:text="Track Study Sessions"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_width="50dp"
android:textColor="#ffffff"
android:textSize="15dp"
android:background="@drawable/mybuttons"> </Button>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/tableRow3">
<Button
android:id="@+id/trackActivities"
android:layout_height="wrap_content"
android:text="Track Class Activities"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_width="50dp"
android:textColor="#ffffff"
android:textSize="15dp"
android:background="@drawable/mybuttons"> </Button>
</TableRow>
</TableLayout>
当我运行在一些屏幕尺寸小于4.5"的手机上时,我无法在日历视图中查看一个月的所有日期。显示如下
在不使用 stock google calendarview 的情况下,是否有解决此问题的方法。 提前致谢
这正在发生,因为您的按钮的高度是 wrap_content
..
因此按钮与您的日历视图重叠
要么尝试使用 ScrollView
参考 This 创建布局。
或
将 LinearLayout
与 weightsum
和 layout_Weight
结合使用。参考 This .