Created
September 16, 2013 05:46
-
-
Save alphamu/6577060 to your computer and use it in GitHub Desktop.
Android LinearLayout with the same height as width.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.widget.LinearLayout; | |
public class SquareLinearLayout extends LinearLayout { | |
public SquareLinearLayout(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
@Override | |
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |
super.onMeasure(widthMeasureSpec, widthMeasureSpec); | |
// or you can use this if you want the square to use height as it basis | |
// super.onMeasure(heightMeasureSpec, heightMeasureSpec); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment