java.lang.Object | ||||
android.view.View | Drawable.Callback KeyEvent.Callback | |||
android.view.ViewGroup | ViewManager ViewParent | |||
android.widget.LinearLayout |
A Layout that arranges its children in a single column or a single row. The direction of the row can be set by calling setOrientation(). You can also specify gravity, which specifies the alignment of all the child elements by calling setGravity() or specify that specific children grow to fill up any remaining space in the layout by setting the weight member of LinearLayout.LayoutParams. The default orientation is horizontal.
Also see android.widget.LinearLayout.LayoutParams for layout attributes
LinearLayout.LayoutParams | Per-child layout information associated with ViewLinearLayout. |
Attribute name | Related methods | |
---|---|---|
android:animationDuration | setAnimationDuration(int) |
Sets how long a transition animation should run (in milliseconds) when layout has changed. |
android:baselineAligned | setBaselineAligned(boolean) |
When set to false, prevents the layout from aligning its children's baselines. |
android:baselineAlignedChildIndex | setBaselineAlignedChildIndex(int) |
When a linear layout is part of another layout that is baseline aligned, it can specify which of its children to baseline align to (i.e which child TextView). |
android:gravity | setGravity(int) |
Specifies how to place an object, both its x and y axis, within a larger containing object. |
android:orientation | setOrientation(int) |
Should the layout be a column or a row? Use "horizontal" for a row, "vertical" for a column. |
Value | ||||
---|---|---|---|---|
int | HORIZONTAL | 0 | 0x00000000 | |
int | VERTICAL | 1 | 0x00000001 |
LinearLayout(Context context) | ||||||
LinearLayout(Context context, AttributeSet attrs) |
LinearLayout.LayoutParams | generateLayoutParams(AttributeSet attrs) | |||||
Returns a new set of layout parameters based on the supplied attributes set. | ||||||
int | getBaseline() | |||||
Return the offset of the widget's text baseline from the widget's top boundary. |
||||||
int | getBaselineAlignedChildIndex() | |||||
int | getOrientation() | |||||
Returns the current orientation. | ||||||
float | getWeightSum() | |||||
Returns the desired weights sum. | ||||||
boolean | isBaselineAligned() | |||||
Indicates whether widgets contained within this layout are aligned on their baseline or not. |
||||||
void | setAnimationDuration(int animationDurationMillis) | |||||
Sets how long the transition animation should run when a chid view changes position. | ||||||
void | setBaselineAligned(boolean baselineAligned) | |||||
Defines whether widgets contained in this layout are baseline-aligned or not. |
||||||
void | setBaselineAlignedChildIndex(int i) | |||||
void | setGravity(int gravity) | |||||
Describes how the child views are positioned. | ||||||
void | setHorizontalGravity(int horizontalGravity) | |||||
void | setOrientation(int orientation) | |||||
Should the layout be a column or a row. | ||||||
void | setVerticalGravity(int verticalGravity) | |||||
void | setWeightSum(float weightSum) | |||||
Defines the desired weights sum. |
boolean | checkLayoutParams(ViewGroup.LayoutParams p) | |||||
LinearLayout.LayoutParams | generateDefaultLayoutParams() | |||||
Returns a set of layout parameters with a width of FILL_PARENT and a height of WRAP_CONTENT when the layout's orientation is VERTICAL. | ||||||
LinearLayout.LayoutParams | generateLayoutParams(ViewGroup.LayoutParams p) | |||||
Returns a safe set of layout parameters based on the supplied layout params. | ||||||
void | onLayout(boolean changed, int l, int t, int r, int b) | |||||
Called from layout when this view should assign a size and position to each of its children. | ||||||
void | onMeasure(int widthMeasureSpec, int heightMeasureSpec) | |||||
Measure the view and its content to determine the measured width and the measured height. |
Must be an integer value, such as "100
".
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.
This corresponds to the global attribute resource symbol animationDuration.
Must be a boolean value, either "true
" or "false
".
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.
This corresponds to the global attribute resource symbol baselineAligned.
Must be an integer value, such as "100
".
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.
This corresponds to the global attribute resource symbol baselineAlignedChildIndex.
Must be one or more (separated by '|') of the following constant values.
Constant | Value | Description |
---|---|---|
top | 0x30 | Push object to the top of its container, not changing its size. |
bottom | 0x50 | Push object to the bottom of its container, not changing its size. |
left | 0x03 | Push object to the left of its container, not changing its size. |
right | 0x05 | Push object to the right of its container, not changing its size. |
center_vertical | 0x10 | Place object in the vertical center of its container, not changing its size. |
fill_vertical | 0x70 | Grow the vertical size of the object if needed so it completely fills its container. |
center_horizontal | 0x01 | Place object in the horizontal center of its container, not changing its size. |
fill_horizontal | 0x07 | Grow the horizontal size of the object if needed so it completely fills its container. |
center | 0x11 | Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. |
fill | 0x77 | Grow the horizontal and vertical size of the object if needed so it completely fills its container. |
This corresponds to the global attribute resource symbol gravity.
Must be one of the following constant values.
Constant | Value | Description |
---|---|---|
horizontal | 0 | Defines an horizontal widget. |
vertical | 1 | Defines a vertical widget. |
This corresponds to the global attribute resource symbol orientation.
attrs | the attributes to build the layout parameters from |
---|
Return the offset of the widget's text baseline from the widget's top boundary. If this widget does not support baseline alignment, this method returns -1.
Indicates whether widgets contained within this layout are aligned on their baseline or not.
animationDurationMillis | How long transition animations should run? |
---|
Defines whether widgets contained in this layout are baseline-aligned or not.
baselineAligned | true to align widgets on their baseline, false otherwise |
---|
i | The index of the child that will be used if this layout is part of a larger layout that is baseline aligned. |
---|
gravity | See Gravity |
---|
orientation | Pass HORIZONTAL or VERTICAL. Default value is HORIZONTAL. |
---|
weightSum | a number greater than 0.0f, or a number lower than or equals to 0.0f if the weight sum should be computed from the children's layout_weight |
---|
p | The layout parameters to convert into a suitable set of layout parameters for this ViewGroup. |
---|
changed | This is a new size or position for this view |
---|---|
l | Left position, relative to parent |
t | Top position, relative to parent |
r | Right position, relative to parent |
b | Bottom position, relative to parent |
Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.
CONTRACT: When overriding this method, you
must call setMeasuredDimension(int, int) to store the
measured width and height of this view. Failure to do so will trigger an
IllegalStateException
, thrown by
measure(int, int). Calling the superclass'
onMeasure(int, int) is a valid use.
The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.
If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).
widthMeasureSpec | horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec. |
---|---|
heightMeasureSpec | vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec. |
Copyright 2007 Google Inc. | Build 0.9_r1-98467 - 14 Aug 2008 18:56 |