Android examples for User Interface:View Margin
Convenience version of set View Margins
//package com.java2s; import android.view.View; import android.view.ViewGroup; public class Main { /** Convenience version of setViewMargins(View view, int left, int top, int right, int bottom) */ public static void setViewMargins(View view, int margin) { setViewMargins(view, margin, margin, margin, margin); }//from w w w . j a v a2s .co m /** Convenience version of setViewMargins(View view, int left, int top, int right, int bottom) */ public static void setViewMargins(View view, int vertical, int horizontal) { setViewMargins(view, horizontal, vertical, horizontal, vertical); } /** Sets the margins for a view in a ViewGroup of type LinearLayout, RelativeLayout, or FrameLayout */ public static void setViewMargins(View view, int left, int top, int right, int bottom) { ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view .getLayoutParams(); params.setMargins(left, top, right, bottom); } }