set Layout Margin Start - Android User Interface

Android examples for User Interface:Layout

Description

set Layout Margin Start

Demo Code

// Copyright 2013 The Chromium Authors. All rights reserved.
//package com.java2s;

import android.os.Build;

import android.view.ViewGroup.MarginLayoutParams;

public class Main {
    /**//from w ww.  j a  va2 s .co m
     * @see android.view.ViewGroup.MarginLayoutParams#setMarginStart(int)
     */
    public static void setMarginStart(MarginLayoutParams layoutParams,
            int start) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            layoutParams.setMarginStart(start);
        } else {
            layoutParams.leftMargin = start;
        }
    }
}

Related Tutorials