예제 #1
0
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int childRight = right - left;
    int childBottom = bottom - top;
    int childLeft = 0;
    int childTop = 0;

    int y = (childBottom - mAvatarSize) / 2;
    childLeft += mSpacing;
    mAvatarDrawable.setBounds(childLeft, y, childLeft + mAvatarSize, y + mAvatarSize);

    childLeft += mAvatarSize + mSpacing;

    if (mButton != null) {
      mButton.layout(childRight - mButtonSize, childTop, childRight, childBottom);
      childRight -= mButtonSize;
    }

    if (mNameView.getVisibility() == View.VISIBLE) {
      if (mAddressView.getVisibility() == View.VISIBLE) {
        childTop =
            (childBottom - mNameView.getMeasuredHeight() - mAddressView.getMeasuredHeight()) / 2;
        mNameView.layout(
            childLeft, childTop, childRight - mSpacing, childTop + mNameView.getMeasuredHeight());
        childTop += mNameView.getMeasuredHeight();
        mAddressView.layout(
            childLeft,
            childTop,
            childRight - mSpacing,
            childTop + mAddressView.getMeasuredHeight());
      } else {
        childTop = (childBottom - mNameView.getMeasuredHeight()) / 2;
        mNameView.layout(
            childLeft, childTop, childRight - mSpacing, childTop + mNameView.getMeasuredHeight());
      }
    } else if (mAddressView.getVisibility() == View.VISIBLE) {
      childTop = (childBottom - mAddressView.getMeasuredHeight()) / 2;
      mAddressView.layout(
          childLeft, childTop, childRight - mSpacing, childTop + mAddressView.getMeasuredHeight());
    }
  }
예제 #2
0
 @Override
 public void draw(Canvas canvas) {
   super.draw(canvas);
   mAvatarDrawable.draw(canvas);
 }
예제 #3
0
 public void setAvatarBitmap(Bitmap bm) {
   mAvatarDrawable.setImage(bm);
   invalidate();
 }