androidx.core.widget


Interfaces

NestedScrollView.OnScrollChangeListener

Interface definition for a callback to be invoked when the scroll X or Y positions of a view change.

TintableCompoundButton

Interface which allows a android.widget.CompoundButton to receive tinting calls from CompoundButtonCompat when running on API v20 devices or lower.

TintableCompoundDrawablesView

Interface which allows android.widget.TextView and subclasses to tint compound drawables with TextViewCompat when running on API v22 devices or lower.

Classes

AutoScrollHelper

AutoScrollHelper is a utility class for adding automatic edge-triggered scrolling to Views.

CheckedTextViewCompat

Helper for accessing CheckedTextView.

CompoundButtonCompat

Helper for accessing CompoundButton.

ContentLoadingProgressBar

ContentLoadingProgressBar implements a ProgressBar that waits a minimum time to be dismissed before showing.

EdgeEffectCompat

Helper for accessing EdgeEffect.

ImageViewCompat

Helper for accessing features in ImageView.

ListPopupWindowCompat

Helper for accessing features in ListPopupWindow.

ListViewAutoScrollHelper

An implementation of AutoScrollHelper that knows how to scroll through a ListView.

ListViewCompat

This class is deprecated.

Use ListView directly.

NestedScrollView

NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android.

PopupMenuCompat

Helper for accessing features in PopupMenu.

PopupWindowCompat

Helper for accessing features in PopupWindow.

RemoteViewsCompat.RemoteCollectionItems

Representation of a fixed list of items to be displayed in a RemoteViews collection.

RemoteViewsCompat.RemoteCollectionItems.Builder

Builder class for RemoteCollectionItems objects.

ScrollerCompat

This class is deprecated.

Use OverScroller directly.

TextViewCompat

Helper for accessing features in TextView.

Objects

RemoteViewsCompat

Helper for accessing features in RemoteViews.

Top-level functions summary

RemoteViews
createExactSizeAppWidget(
    appWidgetManager: AppWidgetManager,
    appWidgetId: Int,
    factory: (SizeFCompat) -> RemoteViews
)

Creates a RemoteViews associated with each size assigned to the app widget by AppWidgetManager, invoking factory to create each alternative view.

RemoteViews
createResponsiveSizeAppWidget(
    appWidgetManager: AppWidgetManager,
    appWidgetId: Int,
    dpSizes: Collection<SizeFCompat>,
    factory: (SizeFCompat) -> RemoteViews
)

Creating a RemoteViews associated with each size provided in dpSizes.

Extension functions summary

inline TextWatcher
TextView.addTextChangedListener(
    crossinline beforeTextChanged: (CharSequence?, start: Int, count: Int, after: Int) -> Unit,
    crossinline onTextChanged: (CharSequence?, start: Int, before: Int, count: Int) -> Unit,
    crossinline afterTextChanged: (Editable?) -> Unit
)

Add a text changed listener to this TextView using the provided actions

inline TextWatcher
TextView.doAfterTextChanged(crossinline action: (Editable?) -> Unit)

Add an action which will be invoked after the text changed.

inline TextWatcher
TextView.doBeforeTextChanged(
    crossinline action: (CharSequence?, start: Int, count: Int, after: Int) -> Unit
)

Add an action which will be invoked before the text changed.

inline TextWatcher
TextView.doOnTextChanged(
    crossinline action: (CharSequence?, start: Int, before: Int, count: Int) -> Unit
)

Add an action which will be invoked when the text is changing.

Unit
AppWidgetManager.updateAppWidget(
    appWidgetId: Int,
    factory: (SizeFCompat) -> RemoteViews
)

Updates the app widget with appWidgetId, creating a RemoteViews for each size assigned to the app widget by AppWidgetManager, invoking factory to create each alternative view.

Unit
AppWidgetManager.updateAppWidget(
    appWidgetId: Int,
    dpSizes: Collection<SizeFCompat>,
    factory: (SizeFCompat) -> RemoteViews
)

Updates the app widget with appWidgetId, creating a RemoteViews for each size provided in dpSizes.

Top-level functions

createExactSizeAppWidget

fun createExactSizeAppWidget(
    appWidgetManager: AppWidgetManager,
    appWidgetId: Int,
    factory: (SizeFCompat) -> RemoteViews
): RemoteViews

Creates a RemoteViews associated with each size assigned to the app widget by AppWidgetManager, invoking factory to create each alternative view.

This provides "exact" sizing , which allows you to tailor your app widget appearance to the exact size at which it is displayed. If you are only concerned with a small number of size thresholds, it is preferable to use "responsive" sizing by providing a fixed set of sizes that your app widget supports.

As your factory may be invoked multiple times, if there is expensive computation of state that is shared among each size, it is recommended to perform that computation before calling this and cache the results as necessary.

To handle resizing of your app widget, it is necessary to call AppWidgetManager.updateAppWidget during both android.appwidget.AppWidgetProvider.onUpdate and android.appwidget.AppWidgetProvider.onAppWidgetOptionsChanged.

Parameters
appWidgetManager: AppWidgetManager

the AppWidgetManager to provide information about appWidgetId

appWidgetId: Int

the id of the app widget

factory: (SizeFCompat) -> RemoteViews

a function to create a RemoteViews for a given width and height (in dp)

createResponsiveSizeAppWidget

fun createResponsiveSizeAppWidget(
    appWidgetManager: AppWidgetManager,
    appWidgetId: Int,
    dpSizes: Collection<SizeFCompat>,
    factory: (SizeFCompat) -> RemoteViews
): RemoteViews

Creating a RemoteViews associated with each size provided in dpSizes.

This provides "responsive" sizing , which allows for smoother resizing and a more consistent experience across different host configurations.

As your factory may be invoked multiple times, if there is expensive computation of state that is shared among each size, it is recommended to perform that computation before calling this and cache the results as necessary.

To handle resizing of your app widget, it is necessary to call AppWidgetManager.updateAppWidget during both android.appwidget.AppWidgetProvider.onUpdate and android.appwidget.AppWidgetProvider.onAppWidgetOptionsChanged. If your app's minSdk is 31 or higher, it is only necessary to call updateAppWidget during onUpdate.

Parameters
appWidgetManager: AppWidgetManager

the AppWidgetManager to provide information about appWidgetId

appWidgetId: Int

the id of the app widget

dpSizes: Collection<SizeFCompat>

a collection of sizes (in dp) that your app widget supports. Must not be empty or contain more than 16 elements.

factory: (SizeFCompat) -> RemoteViews

a function to create a RemoteViews for a given width and height (in dp). It is guaranteed that factory will only ever be called with the values provided in dpSizes.

Extension functions

addTextChangedListener

inline fun TextView.addTextChangedListener(
    crossinline beforeTextChanged: (CharSequence?, start: Int, count: Int, after: Int) -> Unit = { _, _, _, _ -> },
    crossinline onTextChanged: (CharSequence?, start: Int, before: Int, count: Int) -> Unit = { _, _, _, _ -> },
    crossinline afterTextChanged: (Editable?) -> Unit = {}
): TextWatcher

Add a text changed listener to this TextView using the provided actions

Returns
TextWatcher

the TextWatcher added to the TextView

doAfterTextChanged

inline fun TextView.doAfterTextChanged(crossinline action: (Editable?) -> Unit): TextWatcher

Add an action which will be invoked after the text changed.

Returns
TextWatcher

the TextWatcher added to the TextView

doBeforeTextChanged

inline fun TextView.doBeforeTextChanged(
    crossinline action: (CharSequence?, start: Int, count: Int, after: Int) -> Unit
): TextWatcher

Add an action which will be invoked before the text changed.

Returns
TextWatcher

the TextWatcher added to the TextView

doOnTextChanged

inline fun TextView.doOnTextChanged(
    crossinline action: (CharSequence?, start: Int, before: Int, count: Int) -> Unit
): TextWatcher

Add an action which will be invoked when the text is changing.

Returns
TextWatcher

the TextWatcher added to the TextView

updateAppWidget

fun AppWidgetManager.updateAppWidget(
    appWidgetId: Int,
    factory: (SizeFCompat) -> RemoteViews
): Unit

Updates the app widget with appWidgetId, creating a RemoteViews for each size assigned to the app widget by AppWidgetManager, invoking factory to create each alternative view.

This provides "exact" sizing , which allows you to tailor your app widget appearance to the exact size at which it is displayed. If you are only concerned with a small number of size thresholds, it is preferable to use "responsive" sizing by providing a fixed set of sizes that your app widget supports.

As your factory may be invoked multiple times, if there is expensive computation of state that is shared among each size, it is recommended to perform that computation before calling this and cache the results as necessary.

To handle resizing of your app widget, it is necessary to call this function during both android.appwidget.AppWidgetProvider.onUpdate and android.appwidget.AppWidgetProvider.onAppWidgetOptionsChanged.

Parameters
appWidgetId: Int

the id of the app widget

factory: (SizeFCompat) -> RemoteViews

a function to create a RemoteViews for a given width and height (in dp)

updateAppWidget

fun AppWidgetManager.updateAppWidget(
    appWidgetId: Int,
    dpSizes: Collection<SizeFCompat>,
    factory: (SizeFCompat) -> RemoteViews
): Unit

Updates the app widget with appWidgetId, creating a RemoteViews for each size provided in dpSizes.

This provides "responsive" sizing , which allows for smoother resizing and a more consistent experience across different host configurations.

As your factory may be invoked multiple times, if there is expensive computation of state that is shared among each size, it is recommended to perform that computation before calling this and cache the results as necessary.

To handle resizing of your app widget, it is necessary to call this function during both android.appwidget.AppWidgetProvider.onUpdate and android.appwidget.AppWidgetProvider.onAppWidgetOptionsChanged. If your app's minSdk is 31 or higher, it is only necessary to call this function during onUpdate.

Parameters
appWidgetId: Int

the id of the app widget

dpSizes: Collection<SizeFCompat>

a collection of sizes (in dp) that your app widget supports. Must not be empty or contain more than 16 elements.

factory: (SizeFCompat) -> RemoteViews

a function to create a RemoteViews for a given width and height (in dp). It is guaranteed that factory will only ever be called with the values provided in dpSizes.