public class Util
extends java.lang.Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static android.view.ViewGroup.LayoutParams |
getLayoutParamsBasedOnParent(android.view.View view,
int width,
int height)
Create a LayoutParams object for the given view which enforces a given width and height.
|
public static android.view.ViewGroup.LayoutParams getLayoutParamsBasedOnParent(android.view.View view, int width, int height) throws java.lang.IllegalArgumentException
This method is a bit complicated because the TYPE of the LayoutParams that a view must receive (ex. LinearLayout.LayoutParams, RelativeLayout.LayoutParams) depends on the type of its PARENT view.
Thus, in this method, we look at the parent view of the given view, determine its type, and create the appropriate LayoutParams for that type.
This method only supports views which are nested inside a FrameLayout, LinearLayout, or GridLayout.
java.lang.IllegalArgumentException