Closed AkbarBegimkulov closed 6 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?
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
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 {
} ` Unfortunately, corner radius doesn't work. How to make RoundedSquareImageView?