change View width and height - Android User Interface

Android examples for User Interface:View Size

Description

change View width and height

Demo Code


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

public class Main {

    public static void changeWH(View v, int W, int H) {
        LayoutParams params = (LayoutParams) v.getLayoutParams();
        params.width = W;/*from  w  w  w .  j  a v a 2s . co m*/
        params.height = H;
        v.setLayoutParams(params);
    }
}

Related Tutorials