LinearLayoutCompat
open class LinearLayoutCompat : ViewGroup
kotlin.Any | |||
↳ | android.view.View | ||
↳ | android.view.ViewGroup | ||
↳ | androidx.appcompat.widget.LinearLayoutCompat |
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 LinearLayoutCompat.LayoutParams
. The default orientation is horizontal.
See the Linear Layout guide.
Also see LinearLayoutCompat.LayoutParams
for layout attributes
Summary
Nested classes |
|
---|---|
open |
Per-child layout information associated with ViewLinearLayout. |
Constants |
|
---|---|
static Int | |
static Int |
Show a divider at the beginning of the group. |
static Int |
Show a divider at the end of the group. |
static Int |
Show dividers between each item in the group. |
static Int |
Don't show any dividers. |
static Int |
Public constructors |
|
---|---|
<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?) |
|
<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyleAttr: Int) |
Public methods |
|
---|---|
open LinearLayoutCompat.LayoutParams! |
generateLayoutParams(attrs: AttributeSet!) |
open Int | |
open Int | |
open Drawable! | |
open Int |
Get the padding size used to inset dividers in pixels |
open Int |
Returns the current gravity. |
open Int |
Returns the current orientation. |
open Int | |
open Float |
Returns the desired weights sum. |
open Boolean |
Indicates whether widgets contained within this layout are aligned on their baseline or not. |
open Boolean |
When true, all children with a weight will be considered having the minimum size of the largest child. |
open Unit | |
open Unit | |
open Unit |
setBaselineAligned(baselineAligned: Boolean) Defines whether widgets contained in this layout are baseline-aligned or not. |
open Unit | |
open Unit |
setDividerDrawable(divider: Drawable!) Set a drawable to be used as a divider between items. |
open Unit |
setDividerPadding(padding: Int) Set padding displayed on both ends of dividers. |
open Unit |
setGravity(gravity: Int) Describes how the child views are positioned. |
open Unit |
setHorizontalGravity(horizontalGravity: Int) |
open Unit |
setMeasureWithLargestChildEnabled(enabled: Boolean) When set to true, all children with a weight will be considered having the minimum size of the largest child. |
open Unit |
setOrientation(orientation: Int) Should the layout be a column or a row. |
open Unit |
setShowDividers(showDividers: Int) Set how dividers should be shown between items in this layout |
open Unit |
setVerticalGravity(verticalGravity: Int) |
open Unit |
setWeightSum(weightSum: Float) Defines the desired weights sum. |
open Boolean |
Protected methods |
|
---|---|
open Boolean | |
open LinearLayoutCompat.LayoutParams! |
Returns a set of layout parameters with a width of |
open LinearLayoutCompat.LayoutParams! | |
open Unit | |
open Unit | |
open Unit |
Constants
SHOW_DIVIDER_BEGINNING
static val SHOW_DIVIDER_BEGINNING: Int
Show a divider at the beginning of the group.
Value: 1
SHOW_DIVIDER_MIDDLE
static val SHOW_DIVIDER_MIDDLE: Int
Show dividers between each item in the group.
Value: 2
Public constructors
<init>
LinearLayoutCompat(@NonNull context: Context)
<init>
LinearLayoutCompat(@NonNull context: Context, @Nullable attrs: AttributeSet?)
<init>
LinearLayoutCompat(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyleAttr: Int)
Public methods
generateLayoutParams
open fun generateLayoutParams(attrs: AttributeSet!): LinearLayoutCompat.LayoutParams!
getBaseline
open fun getBaseline(): Int
getBaselineAlignedChildIndex
open fun getBaselineAlignedChildIndex(): Int
Return | |
---|---|
Int: The index of the child that will be used if this layout is part of a larger layout that is baseline aligned, or -1 if none has been set. |
getDividerDrawable
open fun getDividerDrawable(): Drawable!
Return | |
---|---|
Drawable!: the divider Drawable that will divide each item. |
See Also
getDividerPadding
open fun getDividerPadding(): Int
Get the padding size used to inset dividers in pixels
getGravity
open fun getGravity(): Int
Returns the current gravity. See android.view.Gravity
Return | |
---|---|
Int: the current gravity. |
See Also
getOrientation
open fun getOrientation(): Int
Returns the current orientation.
Return | |
---|---|
Int: either HORIZONTAL or VERTICAL |
getShowDividers
open fun getShowDividers(): Int
Return | |
---|---|
Int: A flag set indicating how dividers should be shown around items. |
See Also
getWeightSum
open fun getWeightSum(): Float
Returns the desired weights sum.
Return | |
---|---|
Float: A number greater than 0.0f if the weight sum is defined, or a number lower than or equals to 0.0f if not weight sum is to be used. |
isBaselineAligned
open fun isBaselineAligned(): Boolean
Indicates whether widgets contained within this layout are aligned on their baseline or not.
Return | |
---|---|
Boolean: true when widgets are baseline-aligned, false otherwise |
isMeasureWithLargestChildEnabled
open fun isMeasureWithLargestChildEnabled(): Boolean
When true, all children with a weight will be considered having the minimum size of the largest child. If false, all children are measured normally.
Return | |
---|---|
Boolean: True to measure children with a weight using the minimum size of the largest child, false otherwise. |
onInitializeAccessibilityEvent
open fun onInitializeAccessibilityEvent(event: AccessibilityEvent!): Unit
onInitializeAccessibilityNodeInfo
open fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo!): Unit
setBaselineAligned
open fun setBaselineAligned(baselineAligned: Boolean): Unit
Defines whether widgets contained in this layout are baseline-aligned or not.
Parameters | |
---|---|
baselineAligned |
Boolean: true to align widgets on their baseline, false otherwise |
setBaselineAlignedChildIndex
open fun setBaselineAlignedChildIndex(i: Int): Unit
Parameters | |
---|---|
i |
Int: The index of the child that will be used if this layout is part of a larger layout that is baseline aligned. |
setDividerDrawable
open fun setDividerDrawable(divider: Drawable!): Unit
Set a drawable to be used as a divider between items.
Parameters | |
---|---|
divider |
Drawable!: Drawable that will divide each item. |
See Also
setDividerPadding
open fun setDividerPadding(padding: Int): Unit
Set padding displayed on both ends of dividers.
Parameters | |
---|---|
padding |
Int: Padding value in pixels that will be applied to each end |
setGravity
open fun setGravity(gravity: Int): Unit
Describes how the child views are positioned. Defaults to GRAVITY_TOP. If this layout has a VERTICAL orientation, this controls where all the child views are placed if there is extra vertical space. If this layout has a HORIZONTAL orientation, this controls the alignment of the children.
Parameters | |
---|---|
gravity |
Int: See android.view.Gravity |
setMeasureWithLargestChildEnabled
open fun setMeasureWithLargestChildEnabled(enabled: Boolean): Unit
When set to true, all children with a weight will be considered having the minimum size of the largest child. If false, all children are measured normally. Disabled by default.
Parameters | |
---|---|
enabled |
Boolean: True to measure children with a weight using the minimum size of the largest child, false otherwise. |
setOrientation
open fun setOrientation(orientation: Int): Unit
Should the layout be a column or a row.
Parameters | |
---|---|
orientation |
Int: Pass HORIZONTAL or VERTICAL . Default value is HORIZONTAL . |
setShowDividers
open fun setShowDividers(showDividers: Int): Unit
Set how dividers should be shown between items in this layout
Parameters | |
---|---|
showDividers |
Int: One or more of SHOW_DIVIDER_BEGINNING , SHOW_DIVIDER_MIDDLE , or SHOW_DIVIDER_END , or SHOW_DIVIDER_NONE to show no dividers. |
setWeightSum
open fun setWeightSum(weightSum: Float): Unit
Defines the desired weights sum. If unspecified the weights sum is computed at layout time by adding the layout_weight of each child. This can be used for instance to give a single child 50% of the total available space by giving it a layout_weight of 0.5 and setting the weightSum to 1.0.
Parameters | |
---|---|
weightSum |
Float: 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 |
shouldDelayChildPressedState
open fun shouldDelayChildPressedState(): Boolean
Protected methods
checkLayoutParams
protected open fun checkLayoutParams(p: LayoutParams!): Boolean
generateDefaultLayoutParams
protected open fun generateDefaultLayoutParams(): LinearLayoutCompat.LayoutParams!
Returns a set of layout parameters with a width of android.view.ViewGroup.LayoutParams#MATCH_PARENT
and a height of android.view.ViewGroup.LayoutParams#WRAP_CONTENT
when the layout's orientation is VERTICAL
. When the orientation is HORIZONTAL
, the width is set to LayoutParams#WRAP_CONTENT
and the height to LayoutParams#WRAP_CONTENT
.
generateLayoutParams
protected open fun generateLayoutParams(p: LayoutParams!): LinearLayoutCompat.LayoutParams!