English | Site Directory

Android - An Open Handset Alliance Project

android.widget
public class

android.widget.LinearLayout

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

Nested Classes
LinearLayout.LayoutParams Per-child layout information associated with ViewLinearLayout. 
Known Direct Subclasses

Summary

XML Attributes

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. 
XML Attributes inherited from class android.view.ViewGroup
XML Attributes inherited from class android.view.View

Constants

      Value  
int  HORIZONTAL    0x00000000 
int  VERTICAL    0x00000001 
Constants inherited from class android.view.ViewGroup
Constants inherited from class android.view.View

Fields

protected      boolean  mAnimateNextLayout  When this flag is set to true, the next layout pass should animate the children from their old position to their new one. 
Fields inherited from class android.view.ViewGroup
Fields inherited from class android.view.View

Public Constructors

          LinearLayout(Context context)
          LinearLayout(Context context, AttributeSet attrs, Map inflateParams)

Public Methods

        LayoutParams  generateLayoutParams(AttributeSet attrs)
        int  getBaseline()

Return the offset of the widget's text baseline from the widget's top boundary.

        int  getBaselineAlignedChildIndex()
        boolean  isBaselineAligned()

Indicates whether widgets contained within this layout are aligned on their baseline or not.

        void  setAnimateNextLayout(boolean animate)
Sets whether the LinearLayout will animate child views when they move from one position to another
        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)

Protected Methods

        boolean  checkLayoutParams(LayoutParams p)
        int  getChildrenSkipCount(View child, int index)

Returns the number of children to skip after measuring/laying out the specified child.

        int  getLocationOffset(View child)

Return the location offset of the specified child.

        int  getNextLocationOffset(View child)

Return the size offset of the next sibling of the specified child.

        View  getVirtualChildAt(int index)

Returns the view at the specified index.

        int  getVirtualChildCount()

Returns the virtual number of children.

        void  layoutHorizontal()
        void  layoutVertical()
        void  measureChildBeforeLayout(View child, int childIndex, int widthMeasureSpec, int totalWidth, int heightMeasureSpec, int totalHeight)

Measure the child according to the parent's measure specs.

        void  measureHorizontal(int widthMeasureSpec, int heightMeasureSpec)
        int  measureNullChild(int childIndex)

Returns the size (width or height) that should be occupied by a null child.

        void  measureVertical(int widthMeasureSpec, int heightMeasureSpec)
        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.

Methods inherited from class android.view.ViewGroup