vinc3m1 / RoundedImageView

A fast ImageView that supports rounded corners, ovals, and circles.
Other
6.44k stars 1.25k forks source link

RoundedSquareImageView #190

Closed AkbarBegimkulov closed 6 years ago

AkbarBegimkulov commented 7 years ago

I extend RoundedImageView to create SquareImageView with corner radius as below. ` import android.content.Context; import android.util.AttributeSet;

import com.makeramen.roundedimageview.RoundedImageView;

class SquareImageView extends RoundedImageView {

  public SquareImageView(Context context) {
      super(context);
  }

  public SquareImageView(Context context, AttributeSet attrs) {
      super(context, attrs);
  }

  public SquareImageView(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
  }

  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
      setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
  }

} ` Unfortunately, corner radius doesn't work. How to make RoundedSquareImageView?

ghost commented 7 years ago

I did this just by rewriting the onMeasure method and it works fine in my project. I created a gist as below, hope it will help.

https://gist.github.com/Parorisim/806414f0028e56d92146bfc90798afb0