Java android.widget LinearLayout fields, constructors, methods, implement or subclass

Example usage for Java android.widget LinearLayout fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.widget LinearLayout.

The text is from its open source code.

Subclass

android.widget.LinearLayout has subclasses.
Click this link to see all its subclasses.

Field

intHORIZONTAL
intVERTICAL
intSHOW_DIVIDER_NONE
Don't show any dividers.
intSHOW_DIVIDER_BEGINNING
Show a divider at the beginning of the group.
intSHOW_DIVIDER_MIDDLE
Show dividers between each item in the group.
intSHOW_DIVIDER_END
Show a divider at the end of the group.

Constructor

Method

voidaddView(View child)

Adds a child view.

voidaddView(View child, int index)
Adds a child view.
voidaddView(View child, int width, int height)
Adds a child view with this ViewGroup's default layout parameters and the specified width and height.
ViewPropertyAnimatoranimate()
This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.
voidbringToFront()
Change the view's z order in the tree, so it's on top of other sibling views.
voidbuildDrawingCache()

Calling this method is equivalent to calling buildDrawingCache(false).

voiddraw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas.
TfindViewById(@IdRes int id)
Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.
TfindViewWithTag(Object tag)
Look for a child view with the given tag.
DrawablegetBackground()
Gets the background drawable
intgetBottom()
Bottom position of this view relative to its parent.
ViewgetChildAt(int index)
Returns the view at the specified position in the group.
intgetChildCount()
Returns the number of children in the group.
ContextgetContext()
Returns the context the view is running in, through which it can access the current theme, resources, etc.
intgetDividerPadding()
Get the padding size used to inset dividers in pixels
BitmapgetDrawingCache()

Calling this method is equivalent to calling getDrawingCache(false).

intgetHeight()
Return the height of your view.
intgetId()
Returns this view's identifier.
ViewGroup.LayoutParamsgetLayoutParams()
Get the LayoutParams associated with this view.
intgetLeft()
Left position of this view relative to its parent.
intgetMeasuredHeight()
Like #getMeasuredHeightAndState() , but only returns the raw height component (that is the result is masked by #MEASURED_SIZE_MASK ).
intgetMeasuredWidth()
Like #getMeasuredWidthAndState() , but only returns the raw width component (that is the result is masked by #MEASURED_SIZE_MASK ).
intgetMinimumWidth()
Returns the minimum width of the view.
intgetOrientation()
Returns the current orientation.
intgetPaddingBottom()
Returns the bottom padding of this view.
intgetPaddingLeft()
Returns the left padding of this view.
intgetPaddingRight()
Returns the right padding of this view.
intgetPaddingTop()
Returns the top padding of this view.
ViewParentgetParent()
Gets the parent of this view.
ResourcesgetResources()
Returns the resources associated with this view.
intgetRight()
Right position of this view relative to its parent.
ViewgetRootView()

Finds the topmost view in the current view hierarchy.

ObjectgetTag()
Returns this view's tag.
intgetTop()
Top position of this view relative to its parent.
floatgetTranslationY()
The vertical location of this view relative to its #getTop() top position.
ViewTreeObservergetViewTreeObserver()
Returns the ViewTreeObserver for this view's hierarchy.
intgetVisibility()
Returns the visibility status for this view.
intgetWidth()
Return the width of your view.
floatgetY()
The visual y position of this view, in pixels.
intindexOfChild(View child)
Returns the position in the group of the specified child view.
voidinvalidate()
Invalidate the whole view.
booleanisEnabled()
Returns the enabled status for this view.
voidlayout(int l, int t, int r, int b)
voidmeasure(int widthMeasureSpec, int heightMeasureSpec)

This is called to find out how big a view should be.

booleanperformClick()
Call this view's OnClickListener, if it is defined.
booleanpost(Runnable action)

Causes the Runnable to be added to the message queue.

voidremoveAllViews()
Call this method to remove all child views from the ViewGroup.
voidremoveAllViewsInLayout()
Called by a ViewGroup subclass to remove child views from itself, when it must first know its size on screen before it can calculate how many child views it will render.
voidremoveView(View view)

Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.

voidremoveViewAt(int index)
Removes the view at the specified position in the group.
voidremoveViews(int start, int count)
Removes the specified range of views from the group.
booleanrequestFocus()
Call this to try to give focus to a specific view or to one of its descendants.
voidrequestLayout()
Call this when something has changed which has invalidated the layout of this view.
voidsetAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)
Sets the opacity of the view to a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.
voidsetAnimation(Animation animation)
Sets the next animation to play for this view.
voidsetBackground(Drawable background)
Set the background to a given Drawable, or remove the background.
voidsetBackgroundColor(@ColorInt int color)
Sets the background color for this view.
voidsetBackgroundDrawable(Drawable background)
voidsetBackgroundResource(@DrawableRes int resid)
Set the background to a given resource.
voidsetBaselineAligned(boolean baselineAligned)

Defines whether widgets contained in this layout are baseline-aligned or not.

voidsetClickable(boolean clickable)
Enables or disables click events for this view.
voidsetClipChildren(boolean clipChildren)
By default, children are clipped to their bounds before drawing.
voidsetClipToPadding(boolean clipToPadding)
Sets whether this ViewGroup will clip its children to its padding and resize (but not clip) any EdgeEffect to the padded region, if padding is present.
voidsetDescendantFocusability(int focusability)
Set the descendant focusability of this view group.
voidsetDividerDrawable(Drawable divider)
Set a drawable to be used as a divider between items.
voidsetDrawingCacheEnabled(boolean enabled)

Enables or disables the drawing cache.

voidsetElevation(float elevation)
Sets the base elevation of this view, in pixels.
voidsetEnabled(boolean enabled)
Set the enabled state of this view.
voidsetFocusable(boolean focusable)
Set whether this view can receive the focus.
voidsetFocusableInTouchMode(boolean focusableInTouchMode)
Set whether this view can receive focus while in touch mode.
voidsetGravity(int gravity)
Describes how the child views are positioned.
voidsetId(@IdRes int id)
Sets the identifier for this view.
voidsetLayoutParams(ViewGroup.LayoutParams params)
Set the layout parameters associated with this view.
voidsetMeasureWithLargestChildEnabled(boolean enabled)
When set to true, all children with a weight will be considered having the minimum size of the largest child.
voidsetMinimumHeight(int minHeight)
Sets the minimum height of the view.
voidsetMinimumWidth(int minWidth)
Sets the minimum width of the view.
voidsetMotionEventSplittingEnabled(boolean split)
Enable or disable the splitting of MotionEvents to multiple children during touch event dispatch.
voidsetNestedScrollingEnabled(boolean enabled)
Enable or disable nested scrolling for this view.
voidsetNextFocusUpId(int nextFocusUpId)
Sets the id of the view to use when the next focus is #FOCUS_UP .
voidsetOnClickListener(@Nullable OnClickListener l)
Register a callback to be invoked when this view is clicked.
voidsetOnDragListener(OnDragListener l)
Register a drag event listener callback object for this View.
voidsetOnFocusChangeListener(OnFocusChangeListener l)
Register a callback to be invoked when focus of this view changed.
voidsetOnGenericMotionListener(OnGenericMotionListener l)
Register a callback to be invoked when a generic motion event is sent to this view.
voidsetOnHoverListener(OnHoverListener l)
Register a callback to be invoked when a hover event is sent to this view.
voidsetOnKeyListener(OnKeyListener l)
Register a callback to be invoked when a hardware key is pressed in this view.
voidsetOnLongClickListener(@Nullable OnLongClickListener l)
Register a callback to be invoked when this view is clicked and held.
voidsetOnTouchListener(OnTouchListener l)
Register a callback to be invoked when a touch event is sent to this view.
voidsetOrientation(@OrientationMode int orientation)
Should the layout be a column or a row.
voidsetPadding(int left, int top, int right, int bottom)
Sets the padding.
voidsetPressed(boolean pressed)
Sets the pressed state for this view.
voidsetShowDividers(@DividerMode int showDividers)
Set how dividers should be shown between items in this layout
voidsetTag(final Object tag)
Sets the tag associated with this view.
voidsetTranslationY(float translationY)
Sets the vertical location of this view relative to its #getTop() top position.
voidsetVerticalGravity(int verticalGravity)
voidsetVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)

Define whether the vertical scrollbar should be drawn or not.

voidsetVisibility(@Visibility int visibility)
Set the visibility state of this view.
voidsetWeightSum(float weightSum)
Defines the desired weights sum.
voidsetX(float x)
Sets the visual x position of this view, in pixels.
voidsetY(float y)
Sets the visual y position of this view, in pixels.
voidstartAnimation(Animation animation)
Start the specified animation now.
booleanstartDrag(ClipData data, DragShadowBuilder shadowBuilder, Object myLocalState, int flags)