MaterialCalendarView不占用全宽度的android

时间:2017-06-22 09:07:24

标签: android android-layout

我正在放置一个材质日历视图,我希望日历高度占据屏幕的一半,并且它是通过使用布局权重制作的,但日历不占用整个宽度。 还有一个问题是,我想增加日期的文字大小,请参考我的任何想法

XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="symphony.acube.com.symphony.activity.patient.acitivity.mySchedule.MyScheduleActivity">
    <include layout="@layout/toolbar_layout"></include>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/llCalendarContainer"
            android:orientation="vertical"
            android:layout_weight="1">

            <com.prolificinteractive.materialcalendarview.MaterialCalendarView
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/calendarView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:mcv_showOtherDates="all"
                app:mcv_selectionColor="@color/toolbar_red"
                />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1">


        </LinearLayout>
    </LinearLayout>


</LinearLayout>

以下是我目前正在获取的实际窗口

enter image description here

在上面的日历中应该占据全宽,并且日期的文字大小也必须有些大 提前谢谢

1 个答案:

答案 0 :(得分:0)

要拉伸日历的宽度:

measureTileSize减少一个因子(在onMeasure类MaterialCalendarView的方法中)

int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec ((int) (p.height * (measureTileSize / 1.5)), MeasureSpec.EXACTLY);

MonthView

中也是如此
int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec ((int) (measureTileSize / 1.5), MeasureSpec.EXACTLY);

背景出现了一些东西(伸展成椭圆形)

如需了解更多信息,请点击此issue