Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

BoxInsetLayout

@UiThread open class BoxInsetLayout : ViewGroup
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ androidx.wear.widget.BoxInsetLayout

BoxInsetLayout is a screen shape-aware ViewGroup that can box its children in the center square of a round screen by using the boxedEdges attribute. The values for this attribute specify the child's edges to be boxed in: left|top|right|bottom or all. The boxedEdges attribute is ignored on a device with a rectangular screen.

Summary

Nested classes

open

Per-child layout information for layouts that support margins, gravity and boxedEdges.

Public constructors

<init>(@NonNull context: Context)

Simple constructor to use when creating a view from code.

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?)

Constructor that is called when inflating a view from XML.

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, @StyleRes defStyle: Int)

Perform inflation from XML and apply a class-specific base style from a theme attribute.

Public methods

open BoxInsetLayout.LayoutParams!

open Unit
setForeground(drawable: Drawable!)

Protected methods

open Boolean

open LayoutParams!

open Unit

open Unit
onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int)

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Public constructors

<init>

BoxInsetLayout(@NonNull context: Context)

Simple constructor to use when creating a view from code.

Parameters
context Context: The Context the view is running in, through which it can access the current theme, resources, etc.

<init>

BoxInsetLayout(@NonNull context: Context, @Nullable attrs: AttributeSet?)

Constructor that is called when inflating a view from XML. This is called when a view is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet.

The method onFinishInflate() will be called after all children have been added.

Parameters
context Context: The Context the view is running in, through which it can access the current theme, resources, etc.
attrs Context: The attributes of the XML tag that is inflating the view.

<init>

BoxInsetLayout(@NonNull context: Context, @Nullable attrs: AttributeSet?, @StyleRes defStyle: Int)

Perform inflation from XML and apply a class-specific base style from a theme attribute. This constructor allows subclasses to use their own base style when they are inflating.

Parameters
context Context: The Context the view is running in, through which it can access the current theme, resources, etc.
attrs Context: The attributes of the XML tag that is inflating the view.
defStyle Context: An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

Public methods

generateLayoutParams

open fun generateLayoutParams(attrs: AttributeSet!): BoxInsetLayout.LayoutParams!

setForeground

open fun setForeground(drawable: Drawable!): Unit

Protected methods

checkLayoutParams

protected open fun checkLayoutParams(p: LayoutParams!): Boolean

generateLayoutParams

protected open fun generateLayoutParams(p: LayoutParams!): LayoutParams!

onAttachedToWindow

protected open fun onAttachedToWindow(): Unit

onLayout

protected open fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int): Unit

onMeasure

protected open fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit