当前位置: 首页>>代码示例>>Java>>正文


Java Rect.height方法代码示例

本文整理汇总了Java中android.graphics.Rect.height方法的典型用法代码示例。如果您正苦于以下问题:Java Rect.height方法的具体用法?Java Rect.height怎么用?Java Rect.height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Rect的用法示例。


在下文中一共展示了Rect.height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCroppedRect

import android.graphics.Rect; //导入方法依赖的package包/类
private Rect getCroppedRect(Size cameraPreviewSize, Rect visibleRect, int rotation) {
  final int previewWidth  = cameraPreviewSize.width;
  final int previewHeight = cameraPreviewSize.height;

  if (rotation % 180 > 0) rotateRect(visibleRect);

  float scale = (float) previewWidth / visibleRect.width();
  if (visibleRect.height() * scale > previewHeight) {
    scale = (float) previewHeight / visibleRect.height();
  }
  final float newWidth  = visibleRect.width()  * scale;
  final float newHeight = visibleRect.height() * scale;
  final float centerX   = (VERSION.SDK_INT < 14 || isTroublemaker()) ? previewWidth - newWidth / 2 : previewWidth / 2;
  final float centerY   = previewHeight / 2;

  visibleRect.set((int) (centerX - newWidth  / 2),
                  (int) (centerY - newHeight / 2),
                  (int) (centerX + newWidth  / 2),
                  (int) (centerY + newHeight / 2));

  if (rotation % 180 > 0) rotateRect(visibleRect);
  return visibleRect;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:24,代码来源:CameraView.java

示例2: convertOriginalInfo

import android.graphics.Rect; //导入方法依赖的package包/类
public void convertOriginalInfo(ImageView oriView) {
    if (oriView == null || oriView.getDrawable() == null) {
        throw new NullPointerException("original ImageView or ImageView drawable must not null");
    }

    //get original ImageView info
    oriView.getImageMatrix().getValues(mOriginalValues);
    Rect oriRect = oriView.getDrawable().getBounds();
    mOriginalWidth = (int) (oriRect.width() * mOriginalValues[Matrix.MSCALE_X]);
    mOriginalHeight = (int) (oriRect.height() * mOriginalValues[Matrix.MSCALE_Y]);

    mOriginalViewWidth = oriView.getWidth();
    mOriginalViewHeight = oriView.getHeight();
    oriView.getLocationOnScreen(mOriginalLocation);
}
 
开发者ID:idisfkj,项目名称:AndroidShareElement,代码行数:16,代码来源:ShareElementInfo.java

示例3: drawTextToDrawable

import android.graphics.Rect; //导入方法依赖的package包/类
public Bitmap drawTextToDrawable(@DrawableRes int resId, String text, int textSize) {
    Resources resources = _context.getResources();
    float scale = resources.getDisplayMetrics().density;
    Bitmap bitmap = getBitmapFromDrawable(resId);

    bitmap = bitmap.copy(bitmap.getConfig(), true);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.rgb(61, 61, 61));
    paint.setTextSize((int) (textSize * scale));
    paint.setShadowLayer(1f, 0f, 1f, Color.WHITE);

    Rect bounds = new Rect();
    paint.getTextBounds(text, 0, text.length(), bounds);
    int x = (bitmap.getWidth() - bounds.width()) / 2;
    int y = (bitmap.getHeight() + bounds.height()) / 2;
    canvas.drawText(text, x, y, paint);

    return bitmap;
}
 
开发者ID:gsantner,项目名称:markor,代码行数:21,代码来源:ContextUtils.java

示例4: processData

import android.graphics.Rect; //导入方法依赖的package包/类
@Override
public String processData(byte[] data, int width, int height, boolean isRetry) {
    String result = null;
    Image barcode = new Image(width, height, "Y800");

    Rect rect = mScanBoxView.getScanBoxAreaRect(height);
    if (rect != null && !isRetry && rect.left + rect.width() <= width && rect.top + rect.height() <= height) {
        barcode.setCrop(rect.left, rect.top, rect.width(), rect.height());

    }

    barcode.setData(data);
    result = processData(barcode);

    return result;
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:17,代码来源:ZBarView.java

示例5: handleMobileCellScroll

import android.graphics.Rect; //导入方法依赖的package包/类
public boolean handleMobileCellScroll(Rect r) {
    int offset = computeVerticalScrollOffset();
    int height = getHeight();
    int extent = computeVerticalScrollExtent();
    int range = computeVerticalScrollRange();
    int hoverViewTop = r.top;
    int hoverHeight = r.height();

    if (hoverViewTop <= 0 && offset > 0) {
        smoothScrollBy(-mSmoothScrollAmountAtEdge, 0);
        return true;
    }

    if (hoverViewTop + hoverHeight >= height && (offset + extent) < range) {
        smoothScrollBy(mSmoothScrollAmountAtEdge, 0);
        return true;
    }

    return false;
}
 
开发者ID:jpaijh,项目名称:TYT,代码行数:21,代码来源:DynamicGridView.java

示例6: getTransform

import android.graphics.Rect; //导入方法依赖的package包/类
@Override
public Matrix getTransform(
    Matrix outTransform,
    Rect parentRect,
    int childWidth,
    int childHeight,
    float focusX,
    float focusY) {
  final float sX = (float) parentRect.width() / (float) childWidth;
  final float sY = (float) parentRect.height() / (float) childHeight;
  getTransformImpl(outTransform, parentRect, childWidth, childHeight, focusX, focusY, sX, sY);
  return outTransform;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:ScalingUtils.java

示例7: buildLuminanceSource

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * A factory method to build the appropriate LuminanceSource object based on the format
 * of the preview buffers, as described by Camera.Parameters.
 *
 * @param data A preview frame.
 * @param width The width of the image.
 * @param height The height of the image.
 * @return A PlanarYUVLuminanceSource instance.
 */
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {
  Rect rect = getFramingRectInPreview();
  if (rect == null) {
    return null;
  }
  // Go ahead and assume it's YUV rather than die.
  return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
                                      rect.width(), rect.height(), reverseImage);
}
 
开发者ID:mercuriete,项目名称:android-mrz-reader,代码行数:19,代码来源:CameraManager.java

示例8: buildLuminanceSource

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * A factory method to build the appropriate LuminanceSource object based on
 * the format of the preview buffers, as described by Camera.Parameters.
 *
 * @param data   A preview frame.
 * @param width  The width of the image.
 * @param height The height of the image.
 * @return A PlanarYUVLuminanceSource instance.
 */
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {
    // 扫码区域大小,可以调整扫码区域大小
    Rect rect = activity.getCropRect();
    if (rect == null) {
        return null;
    }
    // Go ahead and assume it's YUV rather than die.
    return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, rect.width(), rect
            .height(), false);
}
 
开发者ID:CardInfoLink,项目名称:QRScanner,代码行数:20,代码来源:DecodeHandler.java

示例9: showHint

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * Show a toast message with the hex color code below the view.
 */
public void showHint() {
  final int[] screenPos = new int[2];
  final Rect displayFrame = new Rect();
  getLocationOnScreen(screenPos);
  getWindowVisibleDisplayFrame(displayFrame);
  final Context context = getContext();
  final int width = getWidth();
  final int height = getHeight();
  final int midy = screenPos[1] + height / 2;
  int referenceX = screenPos[0] + width / 2;
  if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) {
    final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
    referenceX = screenWidth - referenceX; // mirror
  }
  StringBuilder hint = new StringBuilder("#");
  if (Color.alpha(color) != 255) {
    hint.append(Integer.toHexString(color).toUpperCase(Locale.ENGLISH));
  } else {
    hint.append(String.format("%06X", 0xFFFFFF & color).toUpperCase(Locale.ENGLISH));
  }
  Toast cheatSheet = Toast.makeText(context, hint.toString(), Toast.LENGTH_SHORT);
  if (midy < displayFrame.height()) {
    // Show along the top; follow action buttons
    cheatSheet.setGravity(Gravity.TOP | GravityCompat.END, referenceX,
        screenPos[1] + height - displayFrame.top);
  } else {
    // Show along the bottom center
    cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
  }
  cheatSheet.show();
}
 
开发者ID:Blankeer,项目名称:MDWechat,代码行数:35,代码来源:ColorPanelView.java

示例10: drawXMetric

import android.graphics.Rect; //导入方法依赖的package包/类
private void drawXMetric(Canvas canvas, Paint textPaint, Paint barPaint) {
    Projection projection = mMap.getProjection();

    if (projection != null) {
        LatLng p1 = projection.fromScreenLocation(new Point((int) ((getWidth() / 2) - (mXdpi / 2)), getHeight() / 2));
        LatLng p2 = projection.fromScreenLocation(new Point((int) ((getWidth() / 2) + (mXdpi / 2)), getHeight() / 2));

        Location locationP1 = new Location("ScaleBar location p1");
        Location locationP2 = new Location("ScaleBar location p2");

        locationP1.setLatitude(p1.latitude);
        locationP2.setLatitude(p2.latitude);
        locationP1.setLongitude(p1.longitude);
        locationP2.setLongitude(p2.longitude);

        float xMetersPerInch = locationP1.distanceTo(locationP2);

        if (mIsLatitudeBar) {
            String xMsg = scaleBarLengthText(xMetersPerInch);
            Rect xTextRect = new Rect();
            textPaint.getTextBounds(xMsg, 0, xMsg.length(), xTextRect);

            int textSpacing = (int) (xTextRect.height() / 5.0);

            canvas.drawRect(mXOffset, mYOffset, mXOffset + mXdpi, mYOffset + mLineWidth, barPaint);
            canvas.drawRect(mXOffset + mXdpi, mYOffset, mXOffset + mXdpi + mLineWidth, mYOffset +
                    xTextRect.height() + mLineWidth + textSpacing, barPaint);

            if (!mIsLongitudeBar) {
                canvas.drawRect(mXOffset, mYOffset, mXOffset + mLineWidth, mYOffset +
                        xTextRect.height() + mLineWidth + textSpacing, barPaint);
            }
            canvas.drawText(xMsg, (mXOffset + mXdpi / 2 - xTextRect.width() / 2),
                    (mYOffset + xTextRect.height() + mLineWidth + textSpacing), textPaint);
        }
    }
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:38,代码来源:ScaleBar.java

示例11: onGlobalLayout

import android.graphics.Rect; //导入方法依赖的package包/类
@Override
public void onGlobalLayout() {
    int navigationBarHeight = 0;
    int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        navigationBarHeight = getResources().getDimensionPixelSize(resourceId);
    }

    // status bar height
    int statusBarHeight = 0;
    resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        statusBarHeight = getResources().getDimensionPixelSize(resourceId);
    }

    // display window size for the app layout
    Rect rect = new Rect();
    getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);

    // screen height - (user app height + status + nav) ..... if non-zero, then there is a soft keyboard
    int keyboardHeight = rootLayout.getRootView().getHeight() - (statusBarHeight + navigationBarHeight + rect.height());

    if (keyboardHeight <= 0) {
        onHideKeyboard();
    } else {
        onShowKeyboard(keyboardHeight);
    }
}
 
开发者ID:aksalj,项目名称:africastalking-android,代码行数:29,代码来源:BaseActivity.java

示例12: computeRadius

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * 计算半径的大小
 */
public void computeRadius(){
    Rect bounds = getBounds();
    radius = bounds.width() < bounds.height() ?
            bounds.width() /2F - margin:
            bounds.height() / 2F - margin;
}
 
开发者ID:qsyj,项目名称:ShortcutMenu,代码行数:10,代码来源:CircleDrawable.java

示例13: estimateItemSize

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * Estimates the size of an item using spans: hSpan, vSpan.
 *
 * @param springLoaded True if we are in spring loaded mode.
 * @param unscaledSize True if caller wants to return the unscaled size
 * @return MAX_VALUE for each dimension if unsuccessful.
 */
public int[] estimateItemSize(ItemInfo itemInfo, boolean springLoaded, boolean unscaledSize) {
    float shrinkFactor = mLauncher.getDeviceProfile().workspaceSpringLoadShrinkFactor;
    int[] size = new int[2];
    if (getChildCount() > 0) {
        // Use the first non-custom page to estimate the child position
        CellLayout cl = (CellLayout) getChildAt(numCustomPages());
        boolean isWidget = itemInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;

        Rect r = estimateItemPosition(cl, 0, 0, itemInfo.spanX, itemInfo.spanY);

        float scale = 1;
        if (isWidget) {
            DeviceProfile profile = mLauncher.getDeviceProfile();
            scale = Utilities.shrinkRect(r, profile.appWidgetScale.x, profile.appWidgetScale.y);
        }
        size[0] = r.width();
        size[1] = r.height();

        if (isWidget && unscaledSize) {
            size[0] /= scale;
            size[1] /= scale;
        }

        if (springLoaded) {
            size[0] *= shrinkFactor;
            size[1] *= shrinkFactor;
        }
        return size;
    } else {
        size[0] = Integer.MAX_VALUE;
        size[1] = Integer.MAX_VALUE;
        return size;
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:42,代码来源:Workspace.java

示例14: getDesiredAnchoredChildRectWithoutConstraints

import android.graphics.Rect; //导入方法依赖的package包/类
private void getDesiredAnchoredChildRectWithoutConstraints(View child, int layoutDirection,
          Rect anchorRect, Rect out, LayoutParams lp, int childWidth, int childHeight) {
      final int absGravity = GravityCompat.getAbsoluteGravity(
              resolveAnchoredChildGravity(lp.gravity), layoutDirection);
      final int absAnchorGravity = GravityCompat.getAbsoluteGravity(
              resolveGravity(lp.anchorGravity),
              layoutDirection);

  final int hgrav = absGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
  final int vgrav = absGravity & Gravity.VERTICAL_GRAVITY_MASK;
  final int anchorHgrav = absAnchorGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
  final int anchorVgrav = absAnchorGravity & Gravity.VERTICAL_GRAVITY_MASK;

  int left;
  int top;

  // Align to the anchor. This puts us in an assumed right/bottom child view gravity.
  // If this is not the case we will subtract out the appropriate portion of
  // the child size below.
  switch (anchorHgrav) {
    default:
    case Gravity.LEFT:
      left = anchorRect.left;
      break;
    case Gravity.RIGHT:
      left = anchorRect.right;
      break;
    case Gravity.CENTER_HORIZONTAL:
      left = anchorRect.left + anchorRect.width() / 2;
      break;
  }

  switch (anchorVgrav) {
    default:
    case Gravity.TOP:
      top = anchorRect.top;
      break;
    case Gravity.BOTTOM:
      top = anchorRect.bottom;
      break;
    case Gravity.CENTER_VERTICAL:
      top = anchorRect.top + anchorRect.height() / 2;
      break;
  }

  // Offset by the child view's gravity itself. The above assumed right/bottom gravity.
  switch (hgrav) {
    default:
    case Gravity.LEFT:
      left -= childWidth;
      break;
    case Gravity.RIGHT:
      // Do nothing, we're already in position.
      break;
    case Gravity.CENTER_HORIZONTAL:
      left -= childWidth / 2;
      break;
  }

  switch (vgrav) {
    default:
    case Gravity.TOP:
      top -= childHeight;
      break;
    case Gravity.BOTTOM:
      // Do nothing, we're already in position.
      break;
    case Gravity.CENTER_VERTICAL:
      top -= childHeight / 2;
      break;
  }

  out.set(left, top, left + childWidth, top + childHeight);
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:75,代码来源:CoordinatorLayout.java

示例15: toScreenPoint

import android.graphics.Rect; //导入方法依赖的package包/类
/**
 * Converts physical coordinate to screen point
 */
public void toScreenPoint(Vector2D fp, Rect r, Point sp)
{
    sp.x = r.left + (int) ((double) r.width() * (fp.x - min.x) / dim.x);
    sp.y = r.bottom - (int) ((double) r.height() * (fp.y - min.y) / dim.y);
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:9,代码来源:PhysicalArea.java


注:本文中的android.graphics.Rect.height方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。