Created SquaredImageView
This commit is contained in:
parent
45657e414f
commit
902d2c77ef
1 changed files with 33 additions and 0 deletions
|
@ -0,0 +1,33 @@
|
||||||
|
package cy.agorise.crystalwallet.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v7.widget.AppCompatImageView;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by xd on 1/24/18.
|
||||||
|
* ImageView which adjusts its size to always create a square
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SquaredImageView extends AppCompatImageView {
|
||||||
|
public SquaredImageView(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SquaredImageView(Context context, @Nullable AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SquaredImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
|
||||||
|
int size = Math.min(getMeasuredWidth(), getMeasuredHeight());
|
||||||
|
setMeasuredDimension(size, size);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue