LinearLayoutCompat
class LinearLayoutCompat : ViewGroup
| kotlin.Any | |||
| ↳ | android.view.View | ||
| ↳ | android.view.ViewGroup | ||
| ↳ | androidx.appcompat.widget.LinearLayoutCompat |
ActionMenuView |
ActionMenuView is a presentation of a series of menu options as a View. |
SearchView |
A widget that provides a user interface for the user to enter a search query and submit a request to a search provider. |
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 types |
|---|
|
Per-child layout information associated with ViewLinearLayout. |
Constants |
|
|---|---|
const Int |
HORIZONTAL = 0 |
const Int |
Show a divider at the beginning of the group. |
const Int |
SHOW_DIVIDER_END = 4Show a divider at the end of the group. |
const Int |
Show dividers between each item in the group. |
const Int |
Don't show any dividers. |
const Int |
VERTICAL = 1 |
Public constructors |
|---|
LinearLayoutCompat(context: Context) |
LinearLayoutCompat(context: Context, attrs: AttributeSet?) |
LinearLayoutCompat( |
Public functions |
|
|---|---|
LinearLayoutCompat.LayoutParams! |
generateLayoutParams(attrs: AttributeSet!) |
Int |
|
Int |
@Attribute(value = "android:baselineAlignedChildIndex") |
Drawable! |
@Attribute(value = "androidx.appcompat:divider") |
Int |
@Attribute(value = "androidx.appcompat:dividerPadding")Get the padding size used to inset dividers in pixels |
@GravityInt Int |
@Attribute(value = "android:gravity")Returns the current gravity. |
Int |
@Attribute(value = "android:orientation", intMapping = [@Attribute.IntMap(name = "horizontal", value = 0), @Attribute.IntMap(name = "vertical", value = 1)])Returns the current orientation. |
Int |
@Attribute(value = "androidx.appcompat:showDividers", intMapping = [@Attribute.IntMap(name = "none", value = 0), @Attribute.IntMap(name = "beginning", value = 1, mask = 1), @Attribute.IntMap(name = "middle", value = 2, mask = 2), @Attribute.IntMap(name = "end", value = 4, mask = 4)]) |
Float |
@Attribute(value = "android:weightSum")Returns the desired weights sum. |
Boolean |
@Attribute(value = "android:baselineAligned")Indicates whether widgets contained within this layout are aligned on their baseline or not. |
Boolean |
@Attribute(value = "androidx.appcompat:measureWithLargestChild")When true, all children with a weight will be considered having the minimum size of the largest child. |
Unit |
|
Unit |
|
Unit |
setBaselineAligned(baselineAligned: Boolean)Defines whether widgets contained in this layout are baseline-aligned or not. |
Unit |
|
Unit |
setDividerDrawable(divider: Drawable!)Set a drawable to be used as a divider between items. |
Unit |
setDividerPadding(padding: Int)Set padding displayed on both ends of dividers. |
Unit |
setGravity(gravity: @GravityInt Int)Describes how the child views are positioned. |
Unit |
setHorizontalGravity(horizontalGravity: Int) |
Unit |
setMeasureWithLargestChildEnabled(enabled: Boolean)When set to true, all children with a weight will be considered having the minimum size of the largest child. |
Unit |
setOrientation(orientation: Int)Should the layout be a column or a row. |
Unit |
setShowDividers(showDividers: Int)Set how dividers should be shown between items in this layout |
Unit |
setVerticalGravity(verticalGravity: Int) |
Unit |
setWeightSum(weightSum: Float)Defines the desired weights sum. |
Boolean |
Protected functions |
|
|---|---|
Boolean |
|
LinearLayoutCompat.LayoutParams! |
Returns a set of layout parameters with a width of |
LinearLayoutCompat.LayoutParams! |
|
Unit |
|
Unit |
|
Unit |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
SHOW_DIVIDER_BEGINNING
const val SHOW_DIVIDER_BEGINNING = 1: Int
Show a divider at the beginning of the group.
SHOW_DIVIDER_END
const val SHOW_DIVIDER_END = 4: Int
Show a divider at the end of the group.
SHOW_DIVIDER_MIDDLE
const val SHOW_DIVIDER_MIDDLE = 2: Int
Show dividers between each item in the group.
Public constructors
LinearLayoutCompat
LinearLayoutCompat(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int
)
Public functions
generateLayoutParams
fun generateLayoutParams(attrs: AttributeSet!): LinearLayoutCompat.LayoutParams!
getBaselineAlignedChildIndex
@Attribute(value = "android:baselineAlignedChildIndex")
fun getBaselineAlignedChildIndex(): Int
| Returns | |
|---|---|
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
@Attribute(value = "androidx.appcompat:divider")
fun getDividerDrawable(): Drawable!
| Returns | |
|---|---|
Drawable! |
the divider Drawable that will divide each item. |
| See also | |
|---|---|
setDividerDrawable |
getDividerPadding
@Attribute(value = "androidx.appcompat:dividerPadding")
fun getDividerPadding(): Int
Get the padding size used to inset dividers in pixels
getGravity
@Attribute(value = "android:gravity")
fun getGravity(): @GravityInt Int
Returns the current gravity. See android.view.Gravity
| Returns | |
|---|---|
@GravityInt Int |
the current gravity. |
| See also | |
|---|---|
setGravity |
getOrientation
@Attribute(value = "android:orientation", intMapping = [@Attribute.IntMap(name = "horizontal", value = 0), @Attribute.IntMap(name = "vertical", value = 1)])
fun getOrientation(): Int
Returns the current orientation.
| Returns | |
|---|---|
Int |
either |
getShowDividers
@Attribute(value = "androidx.appcompat:showDividers", intMapping = [@Attribute.IntMap(name = "none", value = 0), @Attribute.IntMap(name = "beginning", value = 1, mask = 1), @Attribute.IntMap(name = "middle", value = 2, mask = 2), @Attribute.IntMap(name = "end", value = 4, mask = 4)])
fun getShowDividers(): Int
| Returns | |
|---|---|
Int |
A flag set indicating how dividers should be shown around items. |
| See also | |
|---|---|
setShowDividers |
getWeightSum
@Attribute(value = "android:weightSum")
fun getWeightSum(): Float
Returns the desired weights sum.
| Returns | |
|---|---|
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
@Attribute(value = "android:baselineAligned")
fun isBaselineAligned(): Boolean
Indicates whether widgets contained within this layout are aligned on their baseline or not.
| Returns | |
|---|---|
Boolean |
true when widgets are baseline-aligned, false otherwise |
isMeasureWithLargestChildEnabled
@Attribute(value = "androidx.appcompat:measureWithLargestChild")
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.
| Returns | |
|---|---|
Boolean |
True to measure children with a weight using the minimum size of the largest child, false otherwise. |
onInitializeAccessibilityNodeInfo
fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo!): Unit
setBaselineAligned
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
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
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 | |
|---|---|
setShowDividers |
setDividerPadding
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
fun setGravity(gravity: @GravityInt 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: @GravityInt Int |
setMeasureWithLargestChildEnabled
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
fun setOrientation(orientation: Int): Unit
Should the layout be a column or a row.
| Parameters | |
|---|---|
orientation: Int |
Pass |
setShowDividers
fun setShowDividers(showDividers: Int): Unit
Set how dividers should be shown between items in this layout
| Parameters | |
|---|---|
showDividers: Int |
One or more of |
setWeightSum
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 |
Protected functions
generateDefaultLayoutParams
protected fun generateDefaultLayoutParams(): LinearLayoutCompat.LayoutParams!
Returns a set of layout parameters with a width of MATCH_PARENT and a height of WRAP_CONTENT when the layout's orientation is VERTICAL. When the orientation is HORIZONTAL, the width is set to WRAP_CONTENT and the height to WRAP_CONTENT.
generateLayoutParams
protected fun generateLayoutParams(p: ViewGroup.LayoutParams!): LinearLayoutCompat.LayoutParams!