get View Bottom Margin - Android User Interface

Android examples for User Interface:View Margin

Description

get View Bottom Margin

Demo Code


//package com.java2s;

import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class Main {
    public static int getBottomMargin(View view) {
        if (view.getLayoutParams() instanceof LinearLayout.LayoutParams) {
            return ((LinearLayout.LayoutParams) view.getLayoutParams()).bottomMargin;
        } else if (view.getLayoutParams() instanceof RelativeLayout.LayoutParams) {
            return ((RelativeLayout.LayoutParams) view.getLayoutParams()).bottomMargin;
        } else if (view.getLayoutParams() instanceof FrameLayout.LayoutParams) {
            return ((FrameLayout.LayoutParams) view.getLayoutParams()).bottomMargin;
        }/*w  w  w. jav a2 s  . c om*/
        return 0;
    }
}

Related Tutorials