LinearLayoutCompat
public class LinearLayoutCompat extends ViewGroup
| java.lang.Object | |||
| ↳ | 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 |
|---|
public class LinearLayoutCompat.LayoutParams extends LinearLayout.LayoutParamsPer-child layout information associated with ViewLinearLayout. |
Constants |
|
|---|---|
static final int |
HORIZONTAL = 0 |
static final int |
Show a divider at the beginning of the group. |
static final int |
SHOW_DIVIDER_END = 4Show a divider at the end of the group. |
static final int |
Show dividers between each item in the group. |
static final int |
Don't show any dividers. |
static final int |
VERTICAL = 1 |
Public constructors |
|---|
LinearLayoutCompat(@NonNull Context context) |
LinearLayoutCompat(@NonNull Context context, @Nullable AttributeSet attrs) |
LinearLayoutCompat( |
Public methods |
|
|---|---|
LinearLayoutCompat.LayoutParams |
generateLayoutParams(AttributeSet attrs) |
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. |
void |
|
void |
|
void |
setBaselineAligned(boolean baselineAligned)Defines whether widgets contained in this layout are baseline-aligned or not. |
void |
setBaselineAlignedChildIndex(int i) |
void |
setDividerDrawable(Drawable divider)Set a drawable to be used as a divider between items. |
void |
setDividerPadding(int padding)Set padding displayed on both ends of dividers. |
void |
setGravity(@GravityInt int gravity)Describes how the child views are positioned. |
void |
setHorizontalGravity(int horizontalGravity) |
void |
setMeasureWithLargestChildEnabled(boolean enabled)When set to true, all children with a weight will be considered having the minimum size of the largest child. |
void |
setOrientation(int orientation)Should the layout be a column or a row. |
void |
setShowDividers(int showDividers)Set how dividers should be shown between items in this layout |
void |
setVerticalGravity(int verticalGravity) |
void |
setWeightSum(float weightSum)Defines the desired weights sum. |
boolean |
Protected methods |
|
|---|---|
boolean |
|
LinearLayoutCompat.LayoutParams |
Returns a set of layout parameters with a width of |
LinearLayoutCompat.LayoutParams |
|
void |
|
void |
onLayout(boolean changed, int l, int t, int r, int b) |
void |
onMeasure(int widthMeasureSpec, int heightMeasureSpec) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Inherited methods |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
SHOW_DIVIDER_BEGINNING
public static final int SHOW_DIVIDER_BEGINNING = 1
Show a divider at the beginning of the group.
SHOW_DIVIDER_END
public static final int SHOW_DIVIDER_END = 4
Show a divider at the end of the group.
SHOW_DIVIDER_MIDDLE
public static final int SHOW_DIVIDER_MIDDLE = 2
Show dividers between each item in the group.
SHOW_DIVIDER_NONE
public static final int SHOW_DIVIDER_NONE = 0
Don't show any dividers.
Public constructors
LinearLayoutCompat
public LinearLayoutCompat(@NonNull Context context, @Nullable AttributeSet attrs)
LinearLayoutCompat
public LinearLayoutCompat(
@NonNull Context context,
@Nullable AttributeSet attrs,
int defStyleAttr
)
Public methods
generateLayoutParams
public LinearLayoutCompat.LayoutParams generateLayoutParams(AttributeSet attrs)
getBaselineAlignedChildIndex
@Attribute(value = "android:baselineAlignedChildIndex")
public int getBaselineAlignedChildIndex()
| 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")
public Drawable getDividerDrawable()
| Returns | |
|---|---|
Drawable |
the divider Drawable that will divide each item. |
| See also | |
|---|---|
setDividerDrawable |
getDividerPadding
@Attribute(value = "androidx.appcompat:dividerPadding")
public int getDividerPadding()
Get the padding size used to inset dividers in pixels
getGravity
@Attribute(value = "android:gravity")
public @GravityInt int getGravity()
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)])
public int getOrientation()
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)])
public int getShowDividers()
| Returns | |
|---|---|
int |
A flag set indicating how dividers should be shown around items. |
| See also | |
|---|---|
setShowDividers |
getWeightSum
@Attribute(value = "android:weightSum")
public float getWeightSum()
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")
public boolean isBaselineAligned()
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")
public boolean isMeasureWithLargestChildEnabled()
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
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
setBaselineAligned
public void setBaselineAligned(boolean baselineAligned)
Defines whether widgets contained in this layout are baseline-aligned or not.
| Parameters | |
|---|---|
boolean baselineAligned |
true to align widgets on their baseline, false otherwise |
setBaselineAlignedChildIndex
public void setBaselineAlignedChildIndex(int i)
| Parameters | |
|---|---|
int i |
The index of the child that will be used if this layout is part of a larger layout that is baseline aligned. |
setDividerDrawable
public void setDividerDrawable(Drawable divider)
Set a drawable to be used as a divider between items.
| Parameters | |
|---|---|
Drawable divider |
Drawable that will divide each item. |
| See also | |
|---|---|
setShowDividers |
setDividerPadding
public void setDividerPadding(int padding)
Set padding displayed on both ends of dividers.
| Parameters | |
|---|---|
int padding |
Padding value in pixels that will be applied to each end |
setGravity
public void setGravity(@GravityInt int gravity)
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 | |
|---|---|
@GravityInt int gravity |
setMeasureWithLargestChildEnabled
public void setMeasureWithLargestChildEnabled(boolean enabled)
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 | |
|---|---|
boolean enabled |
True to measure children with a weight using the minimum size of the largest child, false otherwise. |
setOrientation
public void setOrientation(int orientation)
Should the layout be a column or a row.
| Parameters | |
|---|---|
int orientation |
Pass |
setShowDividers
public void setShowDividers(int showDividers)
Set how dividers should be shown between items in this layout
| Parameters | |
|---|---|
int showDividers |
One or more of |
setWeightSum
public void setWeightSum(float weightSum)
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 | |
|---|---|
float 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 |
Protected methods
generateDefaultLayoutParams
protected LinearLayoutCompat.LayoutParams generateDefaultLayoutParams()
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 LinearLayoutCompat.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)