Google은 흑인 공동체를 위한 인종 간 평등을 진전시키기 위해 노력하고 있습니다. Google에서 어떤 노력을 하고 있는지 확인하세요.

androidx.core.view

Interfaces

VisibilityListener

Listens to changes in visibility as reported by ActionProvider#refreshVisibility().

OnDragStartListener

Interface definition for a callback to be invoked when a drag start gesture is detected.

LayoutInflaterFactory

Used with LayoutInflaterCompat.setFactory().

OnActionExpandListener

Interface definition for a callback to be invoked when a menu item marked with is expanded or collapsed.

NestedScrollingChild

This interface should be implemented by View subclasses that wish to support dispatching nested scrolling operations to a cooperating parent ViewGroup.

NestedScrollingChild2

This interface should be implemented by View subclasses that wish to support dispatching nested scrolling operations to a cooperating parent ViewGroup.

NestedScrollingChild3

This interface should be implemented by View subclasses that wish to support dispatching nested scrolling operations to a cooperating parent ViewGroup.

NestedScrollingParent

This interface should be implemented by ViewGroup subclasses that wish to support scrolling operations delegated by a nested child view.

NestedScrollingParent2

This interface should be implemented by ViewGroup subclasses that wish to support scrolling operations delegated by a nested child view.

NestedScrollingParent3

This interface should be implemented by ViewGroup subclasses that wish to support scrolling operations delegated by a nested child view.

OnApplyWindowInsetsListener

Listener for applying window insets on a view in a custom way.

ScrollingView

An interface that can be implemented by Views to provide scroll related APIs.

TintableBackgroundView

Interface which allows a android.view.View to receive background tinting calls from ViewCompat when running on API v20 devices or lower.

OnUnhandledKeyEventListenerCompat

Interface definition for a callback to be invoked when a hardware key event hasn't been handled by the view hierarchy.

ViewPropertyAnimatorListener

An animation listener receives notifications from an animation.

ViewPropertyAnimatorUpdateListener

Implementors of this interface can add themselves as update listeners to an ViewPropertyAnimatorCompat instance to receive callbacks on every animation frame, after the current frame's values have been calculated for that ViewPropertyAnimatorCompat.

Classes

AccessibilityDelegateCompat

Helper for accessing AccessibilityDelegate.

ActionProvider

This class is a mediator for accomplishing a given task, for example sharing a file.

DisplayCompat

A class for retrieving the physical display size from a device.

DisplayCutoutCompat

Represents the area of the display that is not functional for displaying content.

DragAndDropPermissionsCompat

Helper for accessing features in android.view.DragAndDropPermissions a backwards compatible fashion.

DragStartHelper

DragStartHelper is a utility class for implementing drag and drop support.

GestureDetectorCompat

Detects various gestures and events using the supplied MotionEvents.

GravityCompat

Compatibility shim for accessing newer functionality from android.view.Gravity.

InputDeviceCompat

Helper class for accessing values in android.view.InputDevice.

LayoutInflaterCompat

Helper for accessing features in LayoutInflater.

MarginLayoutParamsCompat

Helper for accessing API features in MarginLayoutParams in a backwards compatible way.

MenuCompat

Helper for accessing features in android.view.Menu.

MenuItemCompat

Helper for accessing features in android.view.MenuItem.

MotionEventCompat

Helper for accessing features in MotionEvent.

NestedScrollingChildHelper

Helper class for implementing nested scrolling child views compatible with Android platform versions earlier than Android 5.

NestedScrollingParentHelper

Helper class for implementing nested scrolling parent views compatible with Android platform versions earlier than Android 5.

OneShotPreDrawListener

An OnPreDrawListener that will remove itself after one OnPreDraw call.

PointerIconCompat

Helper for accessing features in android.view.PointerIcon in a backwards compatible fashion.

ScaleGestureDetectorCompat

Helper for accessing features in ScaleGestureDetector.

VelocityTrackerCompat

Helper for accessing features in VelocityTracker.

ViewCompat

Helper for accessing features in View.

ViewConfigurationCompat

Helper for accessing features in ViewConfiguration.

ViewGroupCompat

Helper for accessing features in ViewGroup.

ViewParentCompat

Helper for accessing features in ViewParent.

ViewPropertyAnimatorCompat

ViewPropertyAnimatorListenerAdapter

This adapter class provides empty implementations of the methods from ViewPropertyAnimatorListener.

WindowCompat

Helper for accessing features in Window.

WindowInsetsCompat

Describes a set of insets for window content.

Extension functions summary

For android.view.Menu
operator Boolean

Returns true if item is found in this menu.

Unit
Menu.forEach(action: (item: MenuItem) -> Unit)

Performs the given action on each item in this menu.

Unit
Menu.forEachIndexed(action: (index: Int, item: MenuItem) -> Unit)

Performs the given action on each item in this menu, providing its sequential index.

operator MenuItem
Menu.get(index: Int)

Returns the menu at index.

Boolean

Returns true if this menu contains no items.

Boolean

Returns true if this menu contains one or more items.

operator MutableIterator<MenuItem>

Returns a MutableIterator over the items in this menu.

operator Unit

Removes item from this menu.

For android.view.View
Unit
View.doOnAttach(crossinline action: (view: View) -> Unit)

Performs the given action when this view is attached to a window.

Unit
View.doOnDetach(crossinline action: (view: View) -> Unit)

Performs the given action when this view is detached from a window.

Unit
View.doOnLayout(crossinline action: (view: View) -> Unit)

Performs the given action when this view is laid out.

Unit
View.doOnNextLayout(crossinline action: (view: View) -> Unit)

Performs the given action when this view is next laid out.

OneShotPreDrawListener
View.doOnPreDraw(crossinline action: (view: View) -> Unit)

Performs the given action when the view tree is about to be drawn.

Bitmap
View.drawToBitmap(config: Config = Bitmap.Config.ARGB_8888)

Return a Bitmap representation of this View.

Runnable
View.postDelayed(delayInMillis: Long, crossinline action: () -> Unit)

Version of View.postDelayed which re-orders the parameters, allowing the action to be placed outside of parentheses.

Runnable
View.postOnAnimationDelayed(delayInMillis: Long, crossinline action: () -> Unit)

Version of View.postOnAnimationDelayed which re-orders the parameters, allowing the action to be placed outside of parentheses.

Unit
View.setPadding(@Px size: Int)

Sets the view's padding.

Unit

Executes block with the View's layoutParams and reassigns the layoutParams with the updated version.

Unit
View.updateLayoutParams(block: T.() -> Unit)

Executes block with a typed version of the View's layoutParams and reassigns the layoutParams with the updated version.

Unit
View.updatePadding(@Px left: Int = paddingLeft, @Px top: Int = paddingTop, @Px right: Int = paddingRight, @Px bottom: Int = paddingBottom)

Updates this view's padding.

Unit
View.updatePaddingRelative(@Px start: Int = paddingStart, @Px top: Int = paddingTop, @Px end: Int = paddingEnd, @Px bottom: Int = paddingBottom)

Updates this view's relative padding.

For android.view.ViewGroup
operator Boolean

Returns true if view is found in this view group.

Unit
ViewGroup.forEach(action: (view: View) -> Unit)

Performs the given action on each view in this view group.

Unit
ViewGroup.forEachIndexed(action: (index: Int, view: View) -> Unit)

Performs the given action on each view in this view group, providing its sequential index.

operator View
ViewGroup.get(index: Int)

Returns the view at index.

Boolean

Returns true if this view group contains no views.

Boolean

Returns true if this view group contains one or more views.

operator MutableIterator<View>

Returns a MutableIterator over the views in this view group.

operator Unit

Removes view from this view group.

operator Unit

Adds view to this view group.

For android.view.ViewGroup.MarginLayoutParams
Unit

Sets the margins in the ViewGroup's MarginLayoutParams.

Unit
MarginLayoutParams.updateMargins(@Px left: Int = leftMargin, @Px top: Int = topMargin, @Px right: Int = rightMargin, @Px bottom: Int = bottomMargin)

Updates the margins in the ViewGroup's ViewGroup.MarginLayoutParams.

Unit
MarginLayoutParams.updateMarginsRelative(@Px start: Int = marginStart, @Px top: Int = topMargin, @Px end: Int = marginEnd, @Px bottom: Int = bottomMargin)

Updates the relative margins in the ViewGroup's MarginLayoutParams.

Extension properties summary

For android.view.Menu
Sequence<MenuItem>

Returns a Sequence over the items in this menu.

Int

Returns the number of items in this menu.

For android.view.View
Sequence<View>

Returns a Sequence over this view and its descendants recursively.

Sequence<ViewParent>

Returns a Sequence of the parent chain of this view by repeatedly calling View.getParent.

Boolean

Returns true when this view's visibility is View.GONE, false otherwise.

Boolean

Returns true when this view's visibility is View.INVISIBLE, false otherwise.

Boolean

Returns true when this view's visibility is View.VISIBLE, false otherwise.

Int

Returns the bottom margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

Int

Returns the end margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

Int

Returns the left margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

Int

Returns the right margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

Int

Returns the start margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

Int

Returns the top margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

For android.view.ViewGroup
Sequence<View>

Returns a Sequence over the immediate child views in this view group.

Sequence<View>

Returns a Sequence over the child views in this view group recursively.

Int

Returns the number of views in this view group.

Extension functions

contains

operator fun Menu.contains(item: MenuItem): Boolean

Returns true if item is found in this menu.

contains

inline operator fun ViewGroup.contains(view: View): Boolean

Returns true if view is found in this view group.

doOnAttach

inline fun View.doOnAttach(crossinline action: (view: View) -> Unit): Unit

Performs the given action when this view is attached to a window. If the view is already attached to a window the action will be performed immediately, otherwise the action will be performed after the view is next attached.

The action will only be invoked once, and any listeners will then be removed.

See Also

doOnDetach

inline fun View.doOnDetach(crossinline action: (view: View) -> Unit): Unit

Performs the given action when this view is detached from a window. If the view is not attached to a window the action will be performed immediately, otherwise the action will be performed after the view is detached from its current window.

The action will only be invoked once, and any listeners will then be removed.

See Also

doOnLayout

inline fun View.doOnLayout(crossinline action: (view: View) -> Unit): Unit

Performs the given action when this view is laid out. If the view has been laid out and it has not requested a layout, the action will be performed straight away, otherwise the action will be performed after the view is next laid out.

The action will only be invoked once on the next layout and then removed.

See Also

doOnNextLayout

inline fun View.doOnNextLayout(crossinline action: (view: View) -> Unit): Unit

Performs the given action when this view is next laid out.

The action will only be invoked once on the next layout and then removed.

See Also

doOnPreDraw

inline fun View.doOnPreDraw(crossinline action: (view: View) -> Unit): OneShotPreDrawListener

Performs the given action when the view tree is about to be drawn.

The action will only be invoked once prior to the next draw and then removed.

drawToBitmap

fun View.drawToBitmap(config: Config = Bitmap.Config.ARGB_8888): Bitmap

Return a Bitmap representation of this View.

The resulting bitmap will be the same width and height as this view's current layout dimensions. This does not take into account any transformations such as scale or translation.

Note, this will use the software rendering pipeline to draw the view to the bitmap. This may result with different drawing to what is rendered on a hardware accelerated canvas (such as the device screen).

If this view has not been laid out this method will throw a IllegalStateException.

Parameters
config: Config = Bitmap.Config.ARGB_8888 Bitmap config of the desired bitmap. Defaults to Bitmap.Config.ARGB_8888.

forEach

inline fun Menu.forEach(action: (item: MenuItem) -> Unit): Unit

Performs the given action on each item in this menu.

forEach

inline fun ViewGroup.forEach(action: (view: View) -> Unit): Unit

Performs the given action on each view in this view group.

forEachIndexed

inline fun Menu.forEachIndexed(action: (index: Int, item: MenuItem) -> Unit): Unit

Performs the given action on each item in this menu, providing its sequential index.

forEachIndexed

inline fun ViewGroup.forEachIndexed(action: (index: Int, view: View) -> Unit): Unit

Performs the given action on each view in this view group, providing its sequential index.

get

inline operator fun Menu.get(index: Int): MenuItem

Returns the menu at index.

Exceptions
IndexOutOfBoundsException if index is less than 0 or greater than or equal to the count.

get

operator fun ViewGroup.get(index: Int): View

Returns the view at index.

Exceptions
IndexOutOfBoundsException if index is less than 0 or greater than or equal to the count.

isEmpty

inline fun Menu.isEmpty(): Boolean

Returns true if this menu contains no items.

isEmpty

inline fun ViewGroup.isEmpty(): Boolean

Returns true if this view group contains no views.

isNotEmpty

inline fun Menu.isNotEmpty(): Boolean

Returns true if this menu contains one or more items.

isNotEmpty

inline fun ViewGroup.isNotEmpty(): Boolean

Returns true if this view group contains one or more views.

iterator

operator fun Menu.iterator(): MutableIterator<MenuItem>

Returns a MutableIterator over the items in this menu.

iterator

operator fun ViewGroup.iterator(): MutableIterator<View>

Returns a MutableIterator over the views in this view group.

minusAssign

inline operator fun Menu.minusAssign(item: MenuItem): Unit

Removes item from this menu.

minusAssign

inline operator fun ViewGroup.minusAssign(view: View): Unit

Removes view from this view group.

plusAssign

inline operator fun ViewGroup.plusAssign(view: View): Unit

Adds view to this view group.

postDelayed

inline fun View.postDelayed(
    delayInMillis: Long,
    crossinline action: () -> Unit
): Runnable

Version of View.postDelayed which re-orders the parameters, allowing the action to be placed outside of parentheses.

view.postDelayed(200) {
    doSomething()
}
Return
the created Runnable

postOnAnimationDelayed

@RequiresApi(16) inline fun View.postOnAnimationDelayed(
    delayInMillis: Long,
    crossinline action: () -> Unit
): Runnable

Version of View.postOnAnimationDelayed which re-orders the parameters, allowing the action to be placed outside of parentheses.

view.postOnAnimationDelayed(16) {
    doSomething()
}
Return
the created Runnable

setMargins

inline fun MarginLayoutParams.setMargins(@Px size: Int): Unit

Sets the margins in the ViewGroup's MarginLayoutParams. This version of the method sets all axes to the provided size.

setPadding

inline fun View.setPadding(@Px size: Int): Unit

Sets the view's padding. This version of the method sets all axes to the provided size.

See Also

updateLayoutParams

inline fun View.updateLayoutParams(block: LayoutParams.() -> Unit): Unit

Executes block with the View's layoutParams and reassigns the layoutParams with the updated version.

updateLayoutParams

@JvmName("updateLayoutParamsTyped") inline fun <reified T : LayoutParams> View.updateLayoutParams(block: T.() -> Unit): Unit

Executes block with a typed version of the View's layoutParams and reassigns the layoutParams with the updated version.

updateMargins

inline fun MarginLayoutParams.updateMargins(
    @Px left: Int = leftMargin,
    @Px top: Int = topMargin,
    @Px right: Int = rightMargin,
    @Px bottom: Int = bottomMargin
): Unit

Updates the margins in the ViewGroup's ViewGroup.MarginLayoutParams. This version of the method allows using named parameters to just set one or more axes.

updateMarginsRelative

@RequiresApi(17) inline fun MarginLayoutParams.updateMarginsRelative(
    @Px start: Int = marginStart,
    @Px top: Int = topMargin,
    @Px end: Int = marginEnd,
    @Px bottom: Int = bottomMargin
): Unit

Updates the relative margins in the ViewGroup's MarginLayoutParams. This version of the method allows using named parameters to just set one or more axes.

updatePadding

inline fun View.updatePadding(
    @Px left: Int = paddingLeft,
    @Px top: Int = paddingTop,
    @Px right: Int = paddingRight,
    @Px bottom: Int = paddingBottom
): Unit

Updates this view's padding. This version of the method allows using named parameters to just set one or more axes.

See Also

updatePaddingRelative

@RequiresApi(17) inline fun View.updatePaddingRelative(
    @Px start: Int = paddingStart,
    @Px top: Int = paddingTop,
    @Px end: Int = paddingEnd,
    @Px bottom: Int = paddingBottom
): Unit

Updates this view's relative padding. This version of the method allows using named parameters to just set one or more axes.

Extension properties

allViews

val View.allViews: Sequence<View>

Returns a Sequence over this view and its descendants recursively. This is a depth-first traversal similar to View.findViewById. A view with no children will return a single-element sequence of itself.

ancestors

val View.ancestors: Sequence<ViewParent>

Returns a Sequence of the parent chain of this view by repeatedly calling View.getParent. An unattached view will return a zero-element sequence.

children

val Menu.children: Sequence<MenuItem>

Returns a Sequence over the items in this menu.

children

val ViewGroup.children: Sequence<View>

Returns a Sequence over the immediate child views in this view group.

descendants

val ViewGroup.descendants: Sequence<View>

Returns a Sequence over the child views in this view group recursively. This performs a depth-first traversal. A view with no children will return a zero-element sequence.

isGone

inline var View.isGone: Boolean

Returns true when this view's visibility is View.GONE, false otherwise.

if (view.isGone) {
    // Behavior...
}

Setting this property to true sets the visibility to View.GONE, false to View.VISIBLE.

view.isGone = true

isInvisible

inline var View.isInvisible: Boolean

Returns true when this view's visibility is View.INVISIBLE, false otherwise.

if (view.isInvisible) {
    // Behavior...
}

Setting this property to true sets the visibility to View.INVISIBLE, false to View.VISIBLE.

view.isInvisible = true

isVisible

inline var View.isVisible: Boolean

Returns true when this view's visibility is View.VISIBLE, false otherwise.

if (view.isVisible) {
    // Behavior...
}

Setting this property to true sets the visibility to View.VISIBLE, false to View.GONE.

view.isVisible = true

marginBottom

inline val View.marginBottom: Int

Returns the bottom margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

marginEnd

inline val View.marginEnd: Int

Returns the end margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

marginLeft

inline val View.marginLeft: Int

Returns the left margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

marginRight

inline val View.marginRight: Int

Returns the right margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

marginStart

inline val View.marginStart: Int

Returns the start margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

marginTop

inline val View.marginTop: Int

Returns the top margin if this view's LayoutParams is a ViewGroup.MarginLayoutParams, otherwise 0.

size

inline val Menu.size: Int

Returns the number of items in this menu.

size

inline val ViewGroup.size: Int

Returns the number of views in this view group.