Skip to content

Instantly share code, notes, and snippets.

@jinqian
Created August 5, 2013 09:07
Show Gist options
  • Save jinqian/6154496 to your computer and use it in GitHub Desktop.
Save jinqian/6154496 to your computer and use it in GitHub Desktop.
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
public class SquaredImageView extends ImageView {
public SquaredImageView(Context context) {
super(context);
}
public SquaredImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquaredImageView(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());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment