加载NavigationView物料日历视图活动更快时出现问题

时间:2018-12-08 17:18:57

标签: java android

我正在使用Material CalendarView的修改版本,这在我调用onCreate方法时会导致大量加载问题

setContentView(R.layout.content_calendar);

This is my code in its entirety.

有人知道我如何优化代码吗?到目前为止,我已经确定很多问题可能来自这些方法:

CalendarGridView.java:

//This method is needed to get wrap_content height for GridView
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
            MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, expandSpec);

}

CalendarViewPager.java:

//This method is needed to get wrap_content height for ViewPager
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {


    int height = 0;

    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));

        int h = child.getMeasuredHeight();

        if (h > height){
            height = h;
        }
    }

    if (height != 0) {
        heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
    }

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

}

0 个答案:

没有答案