Skip to content

Commit cf6f703

Browse files
author
骆大峰
committed
修改高度获取机制
1 parent 51fd83d commit cf6f703

File tree

5 files changed

+6
-10
lines changed

5 files changed

+6
-10
lines changed

calendar/src/main/java/com/ldf/calendar/view/Calendar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected void onDraw(Canvas canvas) {
5959
@Override
6060
protected void onSizeChanged(int w, int h, int oldW, int oldH) {
6161
super.onSizeChanged(w, h, oldW, oldH);
62-
cellHeight = w / Const.TOTAL_ROW;
62+
cellHeight = h / Const.TOTAL_ROW;
6363
cellWidth = w / Const.TOTAL_COL;
6464
calendarAttr.setCellHeight(cellHeight);
6565
calendarAttr.setCellWidth(cellWidth);

calendar/src/main/java/com/ldf/calendar/view/MonthPager.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class MonthPager extends ViewPager {
1616
private int currentPosition = CURRENT_DAY_INDEX;
1717
private int cellHeight = 0;
1818
private int rowIndex = 6;
19-
private int mCellSpace;
2019

2120
private ViewPager.OnPageChangeListener viewPageChangeListener;
2221
private OnPageChangeListener monthPageChangeListener;
@@ -81,13 +80,13 @@ public void addOnPageChangeListener(OnPageChangeListener listener) {
8180

8281
@Override
8382
protected void onSizeChanged(int w, int h, int oldW, int oldH) {
84-
mCellSpace = h / 6;
83+
cellHeight = h / 6;
8584
super.onSizeChanged(w, h, oldW, oldH);
8685
}
8786

8887
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
89-
if(mCellSpace > 0){
90-
super.onMeasure(widthMeasureSpec,MeasureSpec.makeMeasureSpec(mCellSpace * 6,
88+
if(cellHeight > 0){
89+
super.onMeasure(widthMeasureSpec,MeasureSpec.makeMeasureSpec(cellHeight * 6,
9190
MeasureSpec.EXACTLY));
9291
} else {
9392
super.onMeasure(widthMeasureSpec,heightMeasureSpec);
@@ -113,8 +112,6 @@ public int getTopMovableDistance() {
113112
}
114113

115114
public int getCellHeight() {
116-
CalendarViewAdapter calendarViewAdapter = (CalendarViewAdapter) getAdapter();
117-
cellHeight = calendarViewAdapter.getPagers().get(currentPosition % 3).getCellHeight();
118115
return cellHeight;
119116
}
120117

example/src/main/java/com/hqyxjy/ldf/supercalendar/CustomDayView.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public CustomDayView(Context context, int layoutResource) {
3333
dateTv = (TextView) findViewById(R.id.date);
3434
marker = (ImageView) findViewById(R.id.maker);
3535
selectedBackground = findViewById(R.id.selected_background);
36-
selectedBackground = findViewById(R.id.selected_background);
3736
todayBackground = findViewById(R.id.today_background);
3837
}
3938

example/src/main/res/layout/activity_syllabus.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
<com.ldf.calendar.view.MonthPager
129129
android:id="@+id/calendar_view"
130130
android:layout_width="match_parent"
131-
android:layout_height="360dp"
131+
android:layout_height="300dp"
132132
android:background="#fff">
133133
</com.ldf.calendar.view.MonthPager>
134134

example/src/main/res/layout/custom_day.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:orientation="vertical"
44
android:layout_width="51.4dp"
5-
android:layout_height="60dp">
5+
android:layout_height="50dp">
66
<View
77
android:id="@+id/today_background"
88
android:layout_width="33dp"

0 commit comments

Comments
 (0)