Android examples for User Interface:Layout
set GridLayout Params
import android.support.v7.widget.GridLayout; import android.view.View; import android.view.ViewGroup; public class Main{ public static <T extends View> void setGridLayoutParams(T view, int width, int height, int left, int top, int right, int bottom) { GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams(); layoutParams.width = width;/*from w w w . j a v a2 s .c om*/ layoutParams.height = height; layoutParams.setMargins(left, top, right, bottom); view.setLayoutParams(layoutParams); } public static <T extends View> void setGridLayoutParams(T view, int widthAndHeight, int left, int top, int right, int bottom) { setGridLayoutParams(view, widthAndHeight, widthAndHeight, left, top, right, bottom); } public static <T extends View> void setGridLayoutParams(T view, int width, int height) { setGridLayoutParams(view, width, height, 0, 0, 0, 0); } public static <T extends View> void setGridLayoutParams(T view, int widthAndHeight) { setGridLayoutParams(view, widthAndHeight, widthAndHeight); } }