Skip to content

Instantly share code, notes, and snippets.

@TWiStErRob
Created September 30, 2015 23:33
Show Gist options
  • Save TWiStErRob/f8190f1f55ec1e7777fc to your computer and use it in GitHub Desktop.
Save TWiStErRob/f8190f1f55ec1e7777fc to your computer and use it in GitHub Desktop.
Make GridView or GridLayoutManager items square.
package net.twisterrob.android.view;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
public class SquareFrameLayout extends FrameLayout {
public SquareFrameLayout(Context context) {
super(context);
}
public SquareFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareFrameLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//noinspection SuspiciousNameCombination
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
}
@ShreyashPromact
Copy link

Nice work dude.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment