set View Size by width and height - Android User Interface

Android examples for User Interface:View Size

Description

set View Size by width and height

Demo Code


//package com.java2s;
import android.view.View;
import android.widget.FrameLayout.LayoutParams;

public class Main {
    public static void setSize(View v, int w, int h) {
        LayoutParams lp = (LayoutParams) v.getLayoutParams();
        lp.width = w;/* w ww. j  ava2  s  .c  o m*/
        lp.height = h;
        v.setLayoutParams(lp);
    }
}

Related Tutorials