Android examples for User Interface:View Property
set View Wrap Content
//package com.java2s; import android.view.View; import android.view.ViewGroup; public class Main { public static void setWrapContent(View v) { ViewGroup.LayoutParams lp = v.getLayoutParams(); if (lp == null) { lp = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); v.setLayoutParams(lp);// ww w . j a v a 2s .c o m } else { lp.width = ViewGroup.LayoutParams.WRAP_CONTENT; lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; v.requestLayout(); } } }