set View Margin Bottom - Android User Interface

Android examples for User Interface:View Margin

Description

set View Margin Bottom

Demo Code


//package com.java2s;

import android.view.View;
import android.view.ViewGroup;

public class Main {

    public static void setMarginBottom(View view, int bottom) {
        setMargins(view, 0, 0, 0, bottom);
    }/*from   w ww  .j  a  va  2  s . c  o  m*/

    public static void setMargins(View view, int left, int top, int right,
            int bottom) {
        if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
            ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) view
                    .getLayoutParams();
            p.setMargins(left, top, right, bottom);
            view.requestLayout();
        }
    }
}

Related Tutorials