我想像以下代码一样使用CalendarView
全屏。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<CalendarView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
但此视图高度在设备上显示为wrap_content
。
github中是否有全屏CalendarView
?我找不到 - 或者我可以真正地提出这个观点match_parent
。
任何建议将不胜感激。
答案 0 :(得分:0)
https://github.com/dengshiwei/CalendarComponent
在MonthView中
@override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
if(widthMode == MeasureSpec.AT_MOST){
widthSize = (int) (300 * density);
}
if(heightMode == MeasureSpec.AT_MOST){
heightSize = (int) density * 200;
}
if(widthMode == MeasureSpec.AT_MOST){
widthSize = (int) density * 300;
}
width = widthSize;
NUM_ROWS = 10;
setMeasuredDimension(widthSize, heightSize);
}
上面这段代码使calendarview height match_parent。谢谢你的帮助。
答案 1 :(得分:-1)
试试这种方式。希望这会有所帮助。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<CalendarView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
</CalendarView>
</FrameLayout>
</LinearLayout>