Change size of view. - Android User Interface

Android examples for User Interface:View Size

Description

Change size of view.

Demo Code


//package com.java2s;
import android.view.View;
import android.view.ViewGroup.LayoutParams;

public class Main {
    /**/*ww  w . j  av  a2  s  . co  m*/
     * Change size of view.
     * @param view View to change size.
     * @param width New width.
     * @param height New height.
     */
    public static void setSize(View view, int width, int height) {
        if (view == null)
            return;
        LayoutParams params = view.getLayoutParams();
        params.width = width;
        params.height = height;
        view.requestLayout();
    }
}

Related Tutorials