java.lang.Object | |
↳ | android.view.ViewGroup.LayoutParams |
Known Direct Subclasses |
Known Indirect Subclasses |
LayoutParams are used by views to tell their parents how they want to be
laid out. See
ViewGroup Layout Attributes
for a list of all child view attributes that this class supports.
The base LayoutParams class just describes how big the view wants to be for both width and height. For each dimension, it can specify one of:
For more information about creating user interface layouts, read the XML Layouts developer guide.
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|||||||||
android:layout_height | Specifies the basic height of the view. | ||||||||||
android:layout_width | Specifies the basic width of the view. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | FILL_PARENT | Special value for the height or width requested by a View. | |||||||||
int | MATCH_PARENT | Special value for the height or width requested by a View. | |||||||||
int | WRAP_CONTENT | Special value for the height or width requested by a View. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
height | Information about how tall the view wants to be. | |||||||||
|
layoutAnimationParameters | Used to animate layouts. | |||||||||
|
width | Information about how wide the view wants to be. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Creates a new set of layout parameters.
|
||||||||||
|
Creates a new set of layout parameters with the specified width
and height.
|
||||||||||
|
Copy constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Resolve layout parameters depending on the layout direction.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Extracts the layout parameters from the supplied attributes.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Specifies the basic height of the view. This is a required attribute for any view inside of a containing layout manager. Its value may be a dimension (such as "12dip") for a constant height or one of the special constants.
May be a dimension value, which is a floating point number appended with a unit such as "
14.5sp
".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
May be one of the following constant values.
Constant | Value | Description |
---|---|---|
fill_parent
|
-1 |
The view should be as big as its parent (minus padding).
This constant is deprecated starting from API Level 8 and
is replaced by
match_parent
.
|
match_parent
|
-1 | The view should be as big as its parent (minus padding). Introduced in API Level 8. |
wrap_content
|
-2 | The view should be only big enough to enclose its content (plus padding). |
This corresponds to the global attribute
resource symbol
layout_height
.
Specifies the basic width of the view. This is a required attribute for any view inside of a containing layout manager. Its value may be a dimension (such as "12dip") for a constant width or one of the special constants.
May be a dimension value, which is a floating point number appended with a unit such as "
14.5sp
".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
May be one of the following constant values.
Constant | Value | Description |
---|---|---|
fill_parent
|
-1 |
The view should be as big as its parent (minus padding).
This constant is deprecated starting from API Level 8 and
is replaced by
match_parent
.
|
match_parent
|
-1 | The view should be as big as its parent (minus padding). Introduced in API Level 8. |
wrap_content
|
-2 | The view should be only big enough to enclose its content (plus padding). |
This corresponds to the global attribute
resource symbol
layout_width
.
Special value for the height or width requested by a View.
FILL_PARENT means that the view wants to be as big as its parent,
minus the parent's padding, if any. This value is deprecated
starting in API Level 8 and replaced by
MATCH_PARENT
.
Special value for the height or width requested by a View. MATCH_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any. Introduced in API Level 8.
Special value for the height or width requested by a View. WRAP_CONTENT means that the view wants to be just large enough to fit its own internal content, taking its own padding into account.
Information about how tall the view wants to be. Can be one of the constants FILL_PARENT (replaced by MATCH_PARENT , in API Level 8) or WRAP_CONTENT. or an exact size.
Used to animate layouts.
Information about how wide the view wants to be. Can be one of the constants FILL_PARENT (replaced by MATCH_PARENT , in API Level 8) or WRAP_CONTENT. or an exact size.
Creates a new set of layout parameters. The values are extracted from the supplied attributes set and context. The XML attributes mapped to this set of layout parameters are:
layout_width
: the width, either an exact value,
WRAP_CONTENT
, or
FILL_PARENT
(replaced by
MATCH_PARENT
in API Level 8)
layout_height
: the height, either an exact value,
WRAP_CONTENT
, or
FILL_PARENT
(replaced by
MATCH_PARENT
in API Level 8)
c | the application environment |
---|---|
attrs | the set of attributes from which to extract the layout parameters' values |
Creates a new set of layout parameters with the specified width and height.
width |
the width, either
WRAP_CONTENT
,
FILL_PARENT
(replaced by
MATCH_PARENT
in
API Level 8), or a fixed size in pixels
|
---|---|
height |
the height, either
WRAP_CONTENT
,
FILL_PARENT
(replaced by
MATCH_PARENT
in
API Level 8), or a fixed size in pixels
|
Copy constructor. Clones the width and height values of the source.
source | The layout params to copy from. |
---|
Resolve layout parameters depending on the layout direction. Subclasses that care about layoutDirection changes should override this method. The default implementation does nothing.
layoutDirection |
the direction of the layout
LAYOUT_DIRECTION_LTR
LAYOUT_DIRECTION_RTL
|
---|
Extracts the layout parameters from the supplied attributes.
a | the style attributes to extract the parameters from |
---|---|
widthAttr | the identifier of the width attribute |
heightAttr | the identifier of the height attribute |