Join us on the livestream at Android Dev Summit on 7-8 November 2018, starting at 10AM PDT!

ActionBar

public class ActionBar
extends RelativeLayout

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.RelativeLayout
         ↳ androidx.car.widget.ActionBar


An actions panel with three distinctive zones:

  • Main control: located in the bottom center it shows a highlighted icon and a circular progress bar.
  • Secondary controls: these are displayed at the left and at the right of the main control.
  • Overflow controls: these are displayed at the left and at the right of the secondary controls (if the space allows) and on the additional space if the panel is expanded.

Summary

Nested classes

@interface ActionBar.SlotPosition

 

Constants

int SLOT_EXPAND_COLLAPSE

Slot reserved for the expand/collapse button

int SLOT_LEFT

Slot used to host 'move left', 'rewind', 'previous' or similar secondary actions, usually at the left of the main action on the bottom row

int SLOT_MAIN

Slot used for main actions ActionBar, usually at the bottom center

int SLOT_RIGHT

Slot used to host 'move right', 'fast-forward', 'next' or similar secondary actions, usually at the right of the main action on the bottom row

Inherited constants

Inherited fields

Public constructors

ActionBar(Context context)
ActionBar(Context context, AttributeSet attrs)
ActionBar(Context context, AttributeSet attrs, int defStyleAttrs)
ActionBar(Context context, AttributeSet attrs, int defStyleAttrs, int defStyleRes)

Public methods

void setExpandCollapseView(View view)

Sets the view to use for the expand/collapse action.

void setView(View view, int slotPosition)

Sets or clears the view to be displayed at a particular position.

void setViews(View[] views)

Sets the views to include in each available slot of the action bar.

Inherited methods

Constants

SLOT_EXPAND_COLLAPSE

public static final int SLOT_EXPAND_COLLAPSE

Slot reserved for the expand/collapse button

Constant Value: 3 (0x00000003)

SLOT_LEFT

public static final int SLOT_LEFT

Slot used to host 'move left', 'rewind', 'previous' or similar secondary actions, usually at the left of the main action on the bottom row

Constant Value: 1 (0x00000001)

SLOT_MAIN

public static final int SLOT_MAIN

Slot used for main actions ActionBar, usually at the bottom center

Constant Value: 0 (0x00000000)

SLOT_RIGHT

public static final int SLOT_RIGHT

Slot used to host 'move right', 'fast-forward', 'next' or similar secondary actions, usually at the right of the main action on the bottom row

Constant Value: 2 (0x00000002)

Public constructors

ActionBar

public ActionBar (Context context)

Parameters
context Context

ActionBar

public ActionBar (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

ActionBar

public ActionBar (Context context, 
                AttributeSet attrs, 
                int defStyleAttrs)

Parameters
context Context

attrs AttributeSet

defStyleAttrs int

ActionBar

public ActionBar (Context context, 
                AttributeSet attrs, 
                int defStyleAttrs, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttrs int

defStyleRes int

Public methods

setExpandCollapseView

public void setExpandCollapseView (View view)

Sets the view to use for the expand/collapse action. If not provided, a default ImageButton will be used. The provided View should be able be able to display changes in the "activated" state appropriately.

Parameters
view View: View to use for the expand/collapse action.

setView

public void setView (View view, 
                int slotPosition)

Sets or clears the view to be displayed at a particular position.

Parameters
view View: view to be displayed, or null to leave the position available.

slotPosition int: position to update

setViews

public void setViews (View[] views)

Sets the views to include in each available slot of the action bar. Slots will be filled from start to end (i.e: left to right) and from bottom to top. If more views than available slots are provided, all extra views will be ignored.

Parameters
views View: array of views to include in each available slot.