Android examples for User Interface:View Margin
set Margin For View
//package com.java2s; import android.view.View; import android.view.ViewGroup; public class Main { public static void setMarginForView(View view, int leftMarginInPixels, int topMarginInPixels, int rightMarginInPixels, int bottomMarginInPixels) { if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) view .getLayoutParams();/*from www . ja v a2s. c o m*/ layoutParams.setMargins(leftMarginInPixels, topMarginInPixels, rightMarginInPixels, bottomMarginInPixels); } } }