add Spacer to View - Android User Interface

Android examples for User Interface:View

Description

add Spacer to View

Demo Code

/**/*w ww.  ja va  2  s.  co m*/
 * (c) Winterwell Associates Ltd, used under MIT License. This file is background IP.
 */
//package com.java2s;

import android.view.View;

import android.widget.LinearLayout;

public class Main {
    public static final boolean DEBUG = false;

    public static View addSpacer(LinearLayout row) {
        View spacer = new View(row.getContext());
        //      if (DEBUG) spacer.setBackgroundColor(Color.GREEN);
        android.widget.LinearLayout.LayoutParams params = new android.widget.LinearLayout.LayoutParams(
                DEBUG ? 1 : 0, DEBUG ? 1 : 0, 1);
        row.addView(spacer, params);
        return spacer;
    }
}

Related Tutorials