Java tutorial
//package com.java2s; import android.widget.LinearLayout; import android.widget.RelativeLayout.LayoutParams; public class Main { public static LinearLayout.LayoutParams getWeightParams(float weight, int orientation) { LinearLayout.LayoutParams params = null; if (orientation != LinearLayout.VERTICAL) { // HORIZONTAL params = new LinearLayout.LayoutParams(0, LayoutParams.FILL_PARENT, weight); } else { params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 0, weight); } return params; } }