Back to project page PuppyFrame.
The source code is released under:
MIT License
If you think the Android project PuppyFrame listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.boztalay.puppyframeuid.configuration.views; /*from w w w . j a va 2 s .co m*/ import android.content.Context; import android.util.AttributeSet; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.ImageView; public class SquareImageView extends ImageView { public SquareImageView(Context context) { this(context, null); } public SquareImageView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SquareImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { ViewGroup.LayoutParams layoutParams = getLayoutParams(); layoutParams.height = getMeasuredWidth(); setLayoutParams(layoutParams); getViewTreeObserver().removeOnGlobalLayoutListener(this); } }); } }