@Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
    int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
    int tmpHeightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, heightMode);

    int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
    int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
    int tmpWidthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize, widthMode);

    // fixed scrollview height problems
    if (heightMode == MeasureSpec.UNSPECIFIED
        && getParent() != null
        && (getParent() instanceof ScrollView)) {
      int baseHeight = 0;
      Context context = getContext();
      if (context instanceof Activity) {
        Activity act = (Activity) context;
        int measuredHeight = act.findViewById(android.R.id.content).getMeasuredHeight();
        baseHeight = measuredHeight;
      } else {
        baseHeight = getScreenHeight();
      }
      tmpHeightMeasureSpec = MeasureSpec.makeMeasureSpec(baseHeight, heightMode);
    }

    mPercentLayoutHelper.adjustChildren(tmpWidthMeasureSpec, tmpHeightMeasureSpec);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if (mPercentLayoutHelper.handleMeasuredStateTooSmall()) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
  }