public class PercentLayoutHelper
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PercentLayoutHelper.PercentLayoutInfo
Container for information about percentage dimensions and margins.
|
static interface |
PercentLayoutHelper.PercentLayoutParams
If a layout wants to support percentage based dimensions and use this helper class, its
LayoutParams subclass must implement this interface. |
Constructor and Description |
---|
PercentLayoutHelper(android.view.ViewGroup host) |
Modifier and Type | Method and Description |
---|---|
void |
adjustChildren(int widthMeasureSpec,
int heightMeasureSpec)
Iterates over children and changes their width and height to one calculated from percentage
values.
|
static void |
fetchWidthAndHeight(android.view.ViewGroup.LayoutParams params,
android.content.res.TypedArray array,
int widthAttr,
int heightAttr)
Helper method to be called from
ViewGroup.LayoutParams#setBaseAttributes override
that reads layout_width and layout_height attribute values without throwing an exception if
they aren't present. |
static PercentLayoutHelper.PercentLayoutInfo |
getPercentLayoutInfo(android.content.Context context,
android.util.AttributeSet attrs)
Constructs a PercentLayoutInfo from attributes associated with a View.
|
boolean |
handleMeasuredStateTooSmall()
Iterates over children and checks if any of them would like to get more space than it
received through the percentage dimension.
|
void |
restoreOriginalParams()
Iterates over children and restores their original dimensions that were changed for
percentage values.
|
public static void fetchWidthAndHeight(android.view.ViewGroup.LayoutParams params, android.content.res.TypedArray array, int widthAttr, int heightAttr)
ViewGroup.LayoutParams#setBaseAttributes
override
that reads layout_width and layout_height attribute values without throwing an exception if
they aren't present.public void adjustChildren(int widthMeasureSpec, int heightMeasureSpec)
widthMeasureSpec
- Width MeasureSpec of the parent ViewGroup.heightMeasureSpec
- Height MeasureSpec of the parent ViewGroup.public static PercentLayoutHelper.PercentLayoutInfo getPercentLayoutInfo(android.content.Context context, android.util.AttributeSet attrs)
LayoutParams(Context c, AttributeSet attrs)
constructor.public void restoreOriginalParams()
adjustChildren(int, int)
.public boolean handleMeasuredStateTooSmall()
wrap_content
value. For example
he might specify child's attributes as app:layout_widthPercent="60%p"
and
android:layout_width="wrap_content"
. In this case if the child receives too little
space, it will be remeasured with width set to WRAP_CONTENT
.