HighlightingImageView.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:Quran 作者:
private boolean initOverlayParams(Matrix matrix) {
  if (overlayParams == null || pageBounds == null) {
    return false;
  }

  // Overlay params previously initiated; skip
  if (overlayParams.init) {
    return true;
  }

  int overlayColor = overlayTextColor;
  if (isNightMode) {
    overlayColor = Color.rgb(nightModeTextBrightness,
        nightModeTextBrightness, nightModeTextBrightness);
  }
  overlayParams.paint.setColor(overlayColor);

  // Use font metrics to calculate the maximum possible height of the text
  FontMetrics fm = overlayParams.paint.getFontMetrics();

  final RectF mappedRect = new RectF();
  matrix.mapRect(mappedRect, pageBounds);

  // Calculate where the text's baseline should be
  // (for top text and bottom text)
  // (p.s. parts of the glyphs will be below the baseline such as a
  // 'y' or 'ي')
  overlayParams.topBaseline = -fm.top;
  overlayParams.bottomBaseline = getHeight() - fm.bottom;

  // Calculate the horizontal margins off the edge of screen
  overlayParams.offsetX = Math.min(
      mappedRect.left, getWidth() - mappedRect.right);

  overlayParams.init = true;
  return true;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号