huanghaibin-dev / CalendarView

Android上一个优雅、万能自定义UI、仿iOS、支持垂直、水平方向切换、支持周视图、自定义周起始、性能高效的日历控件,支持热插拔实现的UI定制!支持标记、自定义颜色、农历、自定义月视图各种显示模式等。Canvas绘制,速度快、占用内存低,你真的想不到日历居然还可以如此优雅!An elegant, highly customized and high-performance Calendar Widget on Android.
Apache License 2.0
9.04k stars 1.78k forks source link

3.5.5有个高度的问题 #401

Open TopTime1 opened 5 years ago

TopTime1 commented 5 years ago

CalendarLayout设置默认shrink,展开日历后,底下列表显示不全,请问怎么解决? <com.haibin.calendarview.CalendarLayout android:id="@+id/schedule_calendarLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" app:calendar_show_mode="both_month_week_view" app:calendar_content_view_id="@+id/schedule_calendar_content_view" app:default_status="shrink" app:gesture_mode="disabled">

            <com.haibin.calendarview.CalendarView
                android:id="@+id/schedule_calendarView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/white"
                app:current_day_lunar_text_color="@color/gold"
                app:current_day_text_color="@color/gold"
                app:current_month_lunar_text_color="@color/gray_dark"
                app:current_month_text_color="@color/gray_dark"
                app:day_text_size="@dimen/text_size_14"
                app:lunar_text_size="@dimen/text_size_10"
                app:month_view="com.zwwl.dyw.teacher.view.calendar.CustomMonthView"
                app:month_view_show_mode="mode_only_current"
                app:scheme_lunar_text_color="@color/gray_dark"
                app:scheme_text_color="@color/gray_dark"
                app:scheme_theme_color="@color/gray_dark"
                app:selected_lunar_text_color="@color/white"
                app:selected_text_color="@color/white"
                app:selected_theme_color="@color/gold"
                app:week_background="@color/body_bg"
                app:week_line_background="@color/gray_line"
                app:week_start_with="sun"
                app:week_text_color="@color/gray_dark"
                app:week_view="com.zwwl.dyw.teacher.view.calendar.CustomWeekView" />

            <LinearLayout
                android:id="@+id/schedule_calendar_content_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:descendantFocusability="blocksDescendants"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <View
                        android:layout_width="wrap_content"
                        android:layout_height="1dp"
                        android:layout_weight="1"
                        android:background="@color/f0" />

                    <TextView
                        android:id="@+id/schedule_open_btn"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:background="@drawable/calendar_btn_bg"
                        android:padding="5dp"
                        android:text="展开日历"
                        android:textColor="@color/desk_function_color" />

                    <View
                        android:layout_width="wrap_content"
                        android:layout_height="1dp"
                        android:layout_weight="1"
                        android:background="@color/f0" />
                </LinearLayout>

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/schedule_recyclerView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
            </LinearLayout>
        </com.haibin.calendarview.CalendarLayout>
huanghaibin-dev commented 5 years ago

用法不对,CalendarLayout最好只能嵌套2个子View,如果要多嵌套, RecyclerView 放 LinearLayout里面,LinearLayout实现CalendarScrollView接口接口

TopTime1 commented 5 years ago
        <com.haibin.calendarview.CalendarLayout
            android:id="@+id/schedule_calendarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:calendar_show_mode="both_month_week_view"
            app:calendar_content_view_id="@+id/schedule_recyclerView"
            app:default_status="shrink"
            app:gesture_mode="disabled">

            <com.haibin.calendarview.CalendarView
                android:id="@+id/schedule_calendarView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/white"
                app:current_day_lunar_text_color="@color/gold"
                app:current_day_text_color="@color/gold"
                app:current_month_lunar_text_color="@color/gray_dark"
                app:current_month_text_color="@color/gray_dark"
                app:day_text_size="@dimen/text_size_14"
                app:lunar_text_size="@dimen/text_size_10"
                app:month_view="com.zwwl.dyw.teacher.view.calendar.CustomMonthView"
                app:month_view_show_mode="mode_only_current"
                app:scheme_lunar_text_color="@color/gray_dark"
                app:scheme_text_color="@color/gray_dark"
                app:scheme_theme_color="@color/gray_dark"
                app:selected_lunar_text_color="@color/white"
                app:selected_text_color="@color/white"
                app:selected_theme_color="@color/gold"
                app:week_background="@color/body_bg"
                app:week_line_background="@color/gray_line"
                app:week_start_with="sun"
                app:week_text_color="@color/gray_dark"
                app:week_view="com.zwwl.dyw.teacher.view.calendar.CustomWeekView" />

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/schedule_recyclerView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
        </com.haibin.calendarview.CalendarLayout>

改成这样依然显示不全

huanghaibin-dev commented 5 years ago

明白了,是这个app:gesture_mode="disabled"的问题,去掉就可以

TopTime1 commented 5 years ago

我们的需求是点击展开就展开日历,所以我就禁用了手势,还有个问题,有时候周视图底下会多出一行空白的高度,不知道什么原因?

huanghaibin-dev commented 5 years ago

可以截个图看看吗

TopTime1 commented 5 years ago

image

huanghaibin-dev commented 5 years ago

如何触发的?你开启显示布局测量,看看空白是不是属于日历的一部分?

TopTime1 commented 5 years ago

是的,点击空白区域就收上去了

huanghaibin-dev commented 5 years ago

CalendarLayout只嵌套一个RecyclerView也会吗?

TopTime1 commented 5 years ago

对的

TopTime1 commented 5 years ago

跟最外层嵌套NestedScrollView有关系吗?

huanghaibin-dev commented 5 years ago

有的,要用CalendarLayout,外部不能使用NestedScrollView,否则CalendarLayout的高度就是wrap_content了,这时候你需要自己计算CalendarLayout的高度

TopTime1 commented 5 years ago

我也再看看,先改回3.4.8了,这个还能凑活用,只是底部会有空白

chenyabingsuny commented 3 years ago

我也再看看,先改回3.4.8了,这个还能凑活用,只是底部会有空白

这个显示不全问题最后解决了吗?