Esempio n. 1
0
  /**
   * Draws items
   *
   * @param canvas the canvas for drawing
   */
  private void drawItems(Canvas canvas) {
    canvas.save();

    int top = (currentItem - firstItem) * getItemHeight() + (getItemHeight() - getHeight()) / 2;
    canvas.translate(PADDING, -top + scrollingOffset);

    itemsLayout.draw(canvas);

    canvas.restore();
  }
 public void draw(Canvas canvas) {
   Drawable drawable = mBackground;
   if (drawable != null && mBackgroundSizeChanged) {
     mBackgroundSizeChanged = false;
     Rect rect = mTmp0;
     Rect rect1 = mTmp1;
     mBackground.getPadding(rect1);
     getChildBounds(rect);
     int i = rect.top - rect1.top;
     int j = rect.bottom + rect1.bottom;
     drawable.setBounds(0, i, getRight(), j);
   }
   mBackground.draw(canvas);
   canvas.drawARGB(191, 0, 0, 0);
   super.draw(canvas);
 }
  @Override
  public void draw(Canvas canvas) {
    super.draw(canvas);

    if (foreground != null) {
      final Drawable foreground = this.foreground;

      if (foregroundBoundsChanged) {
        foregroundBoundsChanged = false;

        final int w = getRight() - getLeft();
        final int h = getBottom() - getTop();

        if (foregroundPadding) {
          foreground.setBounds(
              rectPadding.left, rectPadding.top, w - rectPadding.right, h - rectPadding.bottom);
        } else {
          foreground.setBounds(0, 0, w, h);
        }
      }
      foreground.draw(canvas);
    }
  }