ExpandableWidget

public interface ExpandableWidget

Known direct subclasses
ExpandableTransformationWidget

An ExpandableWidget that visually transforms into another component when expanded.

Known indirect subclasses
FloatingActionButton

Floating action buttons are used for a special type of promoted action.


A widget that has expanded/collapsed state. When the expanded state changes, an event is dispatched so that other widgets may react via a .

Implementations of this interface should create an instance of ExpandableWidgetHelper and forward all calls to it.

The expanded state can saved across configuration changes by implementing onSaveInstanceState and onRestoreInstanceState:

@Override
protected Parcelable onSaveInstanceState() {
  Parcelable superState = super.onSaveInstanceState();
  ExtendableSavedState state = new ExtendableSavedState(superState);

  state.extendableStates.put(
      "expandableWidgetHelper", expandableWidgetHelper.onSaveInstanceState());

  return state;
}

@Override
protected void onRestoreInstanceState(Parcelable state) {
  if (!(state instanceof ExtendableSavedState)) {
    super.onRestoreInstanceState(state);
    return;
  }

  ExtendableSavedState ess = (ExtendableSavedState) state;
  super.onRestoreInstanceState(ess.getSuperState());

  expandableWidgetHelper.onRestoreInstanceState(
      ess.extendableStates.get("expandableWidgetHelper"));
}

Summary

Public methods

abstract boolean

Returns whether this widget is expanded.

abstract boolean
setExpanded(boolean expanded)

Sets the expanded state on this widget.

Public methods

isExpanded

abstract boolean isExpanded()

Returns whether this widget is expanded.

Implementations should call isExpanded.

setExpanded

abstract boolean setExpanded(boolean expanded)

Sets the expanded state on this widget.

Implementations should call setExpanded.

Returns
boolean

true if the expanded state changed as a result of this call.