set View Relative Layout Size - Android User Interface

Android examples for User Interface:Layout

Description

set View Relative Layout Size

Demo Code


//package com.java2s;
import android.view.View;
import android.widget.RelativeLayout;

public class Main {
    public static void setRelativeLayoutSize(View v, int width, int height) {
        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) v
                .getLayoutParams();/*from   ww w.  ja v  a2 s. c  o  m*/
        if (lp == null) {
            lp = new RelativeLayout.LayoutParams(width, height);
        } else {
            lp.width = width;
            lp.height = height;
        }
        v.setLayoutParams(lp);
    }
}

Related Tutorials