Skip to content

Instantly share code, notes, and snippets.

@fcaldarelli
Created December 2, 2016 20:57
Show Gist options
  • Save fcaldarelli/75f52c3dd01a6c8fd60f60d56840c11b to your computer and use it in GitHub Desktop.
Save fcaldarelli/75f52c3dd01a6c8fd60f60d56840c11b to your computer and use it in GitHub Desktop.
Square Percent Relative Layout
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.support.percent.PercentRelativeLayout;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
public class SquarePercentRelativeLayout extends PercentRelativeLayout {
public SquarePercentRelativeLayout(Context context) {
super(context);
}
public SquarePercentRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquarePercentRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Set a square layout.
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment