Android examples for User Interface:View Size
set View Height
//package com.java2s; import android.view.View; import android.view.ViewGroup; public class Main { public static void setHeight(View view, int height) { ViewGroup.LayoutParams lp = view.getLayoutParams(); if (null == lp) { lp = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); }/* w w w . ja v a 2s .co m*/ lp.height = height; view.setLayoutParams(lp); } public static void setHeight(View view, float height) { ViewGroup.LayoutParams lp = view.getLayoutParams(); if (null == lp) { lp = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); } lp.height = (int) height; view.setLayoutParams(lp); } }