Android Studio
Added in API level 16

MediaRouteButton


public class MediaRouteButton
extends View

java.lang.Object
   ↳ android.view.View
     ↳ android.app.MediaRouteButton


Summary

Inherited XML attributes

From class android.view.View android:accessibilityHeading Whether or not this view is a heading for accessibility purposes.  android:accessibilityLiveRegion Indicates to accessibility services whether the user should be notified when this view changes.  android:accessibilityPaneTitle The title this view should present to accessibility as a pane title.  android:accessibilityTraversalAfter Sets the id of a view that screen readers are requested to visit before this view.  android:accessibilityTraversalBefore Sets the id of a view that screen readers are requested to visit after this view.  android:allowClickWhenDisabled Whether or not allow clicks on disabled view.  android:alpha alpha property of the view, as a value between 0 (completely transparent) and 1 (completely opaque).  android:autoHandwritingEnabled Whether or not the auto handwriting initiation is enabled in this View.  android:autofillHints Describes the content of a view so that a autofill service can fill in the appropriate data.  android:autofilledHighlight Drawable to be drawn over the view to mark it as autofilled May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".  android:background A drawable to use as the background.  android:backgroundTint Tint to apply to the background.  android:backgroundTintMode Blending mode used to apply the background tint.  android:clickable Defines whether this view reacts to click events.  android:clipToOutline Whether the View's Outline should be used to clip the contents of the View.  android:contentDescription Defines text that briefly describes content of the view.  android:contextClickable Defines whether this view reacts to context click events.  android:defaultFocusHighlightEnabled Whether this View should use a default focus highlight when it gets focused but doesn't have R.attr.state_focused defined in its background.  android:drawingCacheQuality Defines the quality of translucent drawing caches.  android:duplicateParentState When this attribute is set to true, the view gets its drawable state (focused, pressed, etc.) from its direct parent rather than from itself.  android:elevation base z depth of the view.  android:fadeScrollbars Defines whether to fade out scrollbars when they are not in use.  android:fadingEdgeLength Defines the length of the fading edges.  android:filterTouchesWhenObscured Specifies whether to filter touches when the view's window is obscured by another visible window.  android:fitsSystemWindows Boolean internal attribute to adjust view layout based on system windows such as the status bar.  android:focusable Controls whether a view can take focus.  android:focusableInTouchMode Boolean that controls whether a view can take focus while in touch mode.  android:focusedByDefault Whether this view is a default-focus view.  android:forceHasOverlappingRendering Whether this view has elements that may overlap when drawn.  android:foreground Defines the drawable to draw over the content.  android:foregroundGravity Defines the gravity to apply to the foreground drawable.  android:foregroundTint Tint to apply to the foreground.  android:foregroundTintMode Blending mode used to apply the foreground tint.  android:hapticFeedbackEnabled Boolean that controls whether a view should have haptic feedback enabled for events such as long presses.  android:id Supply an identifier name for this view, to later retrieve it with View.findViewById() or Activity.findViewById()android:importantForAccessibility Describes whether or not this view is important for accessibility.  android:importantForAutofill Hints the Android System whether the view node associated with this View should be included in a view structure used for autofill purposes.  android:importantForContentCapture Hints the Android System whether the view node associated with this View should be use for content capture purposes.  android:isCredential This is deprecated. The isCredential attr is no longer needed. May be a boolean value, such as "true" or "false".  android:isScrollContainer Set this if the view will serve as a scrolling container, meaning that it can be resized to shrink its overall window so that there will be space for an input method.  android:keepScreenOn Controls whether the view's window should keep the screen on while visible.  android:keyboardNavigationCluster Whether this view is a root of a keyboard navigation cluster.  android:layerType Specifies the type of layer backing this view.  android:layoutDirection Defines the direction of layout drawing.  android:longClickable Defines whether this view reacts to long click events.  android:minHeight Defines the minimum height of the view.  android:minWidth Defines the minimum width of the view.  android:nextClusterForward Defines the next keyboard navigation cluster.  android:nextFocusDown Defines the next view to give focus to when the next focus is View.FOCUS_DOWN If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed.  android:nextFocusForward Defines the next view to give focus to when the next focus is View.FOCUS_FORWARD If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed.  android:nextFocusLeft Defines the next view to give focus to when the next focus is View.FOCUS_LEFTandroid:nextFocusRight Defines the next view to give focus to when the next focus is View.FOCUS_RIGHT If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed.  android:nextFocusUp Defines the next view to give focus to when the next focus is View.FOCUS_UP If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed.  android:onClick This is deprecated. View actually traverses the Context hierarchy looking for the relevant method, which is fragile (an intermediate ContextWrapper adding a same-named method would change behavior) and restricts bytecode optimizers such as R8. Instead, use View.setOnClickListener.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;  android:outlineAmbientShadowColor Sets the color of the ambient shadow that is drawn when the view has a positive Z or elevation value.  android:outlineSpotShadowColor Sets the color of the spot shadow that is drawn when the view has a positive Z or elevation value.  android:padding Sets the padding, in pixels, of all four edges.  android:paddingBottom Sets the padding, in pixels, of the bottom edge; see R.attr.paddingandroid:paddingEnd Sets the padding, in pixels, of the end edge; see R.attr.paddingandroid:paddingHorizontal Sets the padding, in pixels, of the left and right edges; see R.attr.paddingandroid:paddingLeft Sets the padding, in pixels, of the left edge; see R.attr.paddingandroid:paddingRight Sets the padding, in pixels, of the right edge; see R.attr.paddingandroid:paddingStart Sets the padding, in pixels, of the start edge; see R.attr.paddingandroid:paddingTop Sets the padding, in pixels, of the top edge; see R.attr.paddingandroid:paddingVertical Sets the padding, in pixels, of the top and bottom edges; see R.attr.paddingandroid:preferKeepClear

Sets a preference to keep the bounds of this view clear from floating windows above this view's window.  android:requiresFadingEdge Defines which edges should be faded on scrolling.  android:rotation rotation of the view, in degrees.  android:rotationX rotation of the view around the x axis, in degrees.  android:rotationY rotation of the view around the y axis, in degrees.  android:saveEnabled If false, no state will be saved for this view when it is being frozen.  android:scaleX scale of the view in the x direction.  android:scaleY scale of the view in the y direction.  android:screenReaderFocusable Whether this view should be treated as a focusable unit by screen reader accessibility tools.  android:scrollIndicators Defines which scroll indicators should be displayed when the view can be scrolled.  android:scrollX The initial horizontal scroll offset, in pixels.  android:scrollY The initial vertical scroll offset, in pixels.  android:scrollbarAlwaysDrawHorizontalTrack Defines whether the horizontal scrollbar track should always be drawn.  android:scrollbarAlwaysDrawVerticalTrack Defines whether the vertical scrollbar track should always be drawn.  android:scrollbarDefaultDelayBeforeFade Defines the delay in milliseconds that a scrollbar waits before fade out.  android:scrollbarFadeDuration Defines the delay in milliseconds that a scrollbar takes to fade out.  android:scrollbarSize Sets the width of vertical scrollbars and height of horizontal scrollbars.  android:scrollbarStyle Controls the scrollbar style and position.  android:scrollbarThumbHorizontal Defines the horizontal scrollbar thumb drawable.  android:scrollbarThumbVertical Defines the vertical scrollbar thumb drawable.  android:scrollbarTrackHorizontal Defines the horizontal scrollbar track drawable.  android:scrollbarTrackVertical Defines the vertical scrollbar track drawable.  android:scrollbars Defines which scrollbars should be displayed on scrolling or not.  android:soundEffectsEnabled Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching.  android:stateListAnimator Sets the state-based animator for the View.  android:supplementalDescription Provides brief supplemental information for the view, such as the purpose of the view when that purpose is not conveyed within its textual representation.  android:tag Supply a tag for this view containing a String, to be retrieved later with View.getTag() or searched for with View.findViewWithTag()android:textAlignment Defines the alignment of the text.  android:textDirection Defines the direction of the text.  android:theme Specifies a theme override for a view.  android:tooltipText Defines text displayed in a small popup window on hover or long press.  android:transformPivotX x location of the pivot point around which the view will rotate and scale.  android:transformPivotY y location of the pivot point around which the view will rotate and scale.  android:transitionName Names a View such that it can be identified for Transitions.  android:translationX translation in x of the view.  android:translationY translation in y of the view.  android:translationZ translation in z of the view.  android:visibility Controls the initial visibility of the view. 

Inherited constants

Inherited fields

Public constructors

MediaRouteButton(Context context)
MediaRouteButton(Context context, AttributeSet attrs)
MediaRouteButton(Context context, AttributeSet attrs, int defStyleAttr)
MediaRouteButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public methods

int getRouteTypes()

Gets the media route types for filtering the routes that the user can select using the media route chooser dialog.

void jumpDrawablesToCurrentState()

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

void onAttachedToWindow()

This is called when the view is attached to a window.

void onDetachedFromWindow()

This is called when the view is detached from a window.

boolean performClick()

Call this view's OnClickListener, if it is defined.

void setContentDescription(CharSequence contentDescription)

Sets the View's content description.

void setExtendedSettingsClickListener(View.OnClickListener listener)
void setRouteTypes(int types)

Sets the types of routes that will be shown in the media route chooser dialog launched by this button.

void setVisibility(int visibility)

Set the visibility state of this view.

void showDialog()

Show the route chooser or controller dialog.

Protected methods

void drawableStateChanged()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

int[] onCreateDrawableState(int extraSpace)

Generate the new Drawable state for this view.

void onDraw(Canvas canvas)

Implement this to do your drawing.

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

boolean verifyDrawable(Drawable who)

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.

Inherited methods

Public constructors

MediaRouteButton

Added in API level 16
public MediaRouteButton (Context context)

Parameters
context Context

MediaRouteButton

Added in API level 16
public MediaRouteButton (Context context, 
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

MediaRouteButton

Added in API level 16
public MediaRouteButton (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context
attrs AttributeSet
defStyleAttr int

MediaRouteButton

Added in API level 21
public MediaRouteButton (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context
attrs AttributeSet
defStyleAttr int
defStyleRes int

Public methods

getRouteTypes

Added in API level 16
public int getRouteTypes ()

Gets the media route types for filtering the routes that the user can select using the media route chooser dialog.

Returns
int The route types.

jumpDrawablesToCurrentState

Added in API level 16
public void jumpDrawablesToCurrentState ()

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

Also calls StateListAnimator.jumpToCurrentState() if there is a StateListAnimator attached to this view.
If you override this method you must call through to the superclass implementation.

onAttachedToWindow

Added in API level 16
public void onAttachedToWindow ()

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).
If you override this method you must call through to the superclass implementation.

onDetachedFromWindow

Added in API level 16
public void onDetachedFromWindow ()

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
If you override this method you must call through to the superclass implementation.

performClick

Added in API level 16
public boolean performClick ()

Call this view's OnClickListener, if it is defined. Performs all normal actions associated with clicking: reporting accessibility event, playing a sound, etc.

Returns
boolean True there was an assigned OnClickListener that was called, false otherwise is returned.

setContentDescription

Added in API level 16
public void setContentDescription (CharSequence contentDescription)

Sets the View's content description.

A content description briefly describes the view and is primarily used for accessibility support to determine how a view should be presented to the user. In the case of a view with no textual representation, such as ImageButton, a useful content description explains what the view does. For example, an image button with a phone icon that is used to place a call may use "Call" as its content description. An image of a floppy disk that is used to save a file may use "Save".

This should omit role or state. Role refers to the kind of user-interface element the View is, such as a Button or Checkbox. State refers to a frequently changing property of the View, such as an On/Off state of a button or the audio level of a volume slider.

Content description updates are not frequent, and are used when the semantic content - not the state - of the element changes. For example, a Play button might change to a Pause button during music playback.

Parameters
contentDescription CharSequence: The content description.

setExtendedSettingsClickListener

Added in API level 16
public void setExtendedSettingsClickListener (View.OnClickListener listener)

Parameters
listener View.OnClickListener

setRouteTypes

Added in API level 16
public void setRouteTypes (int types)

Sets the types of routes that will be shown in the media route chooser dialog launched by this button.

Parameters
types int: The route types to match.

setVisibility

Added in API level 16
public void setVisibility (int visibility)

Set the visibility state of this view.

Parameters visibility int: One of View.VISIBLE, View.INVISIBLE, or View.GONE.
Value is one of the following:

showDialog

Added in API level 16
public void showDialog ()

Show the route chooser or controller dialog.

If the default route is selected or if the currently selected route does not match the route types, then shows the route chooser dialog. Otherwise, shows the route controller dialog to offer the user a choice to disconnect from the route or perform other control actions such as setting the route's volume.

This will attach a DialogFragment to the containing Activity.

Protected methods

drawableStateChanged

Added in API level 16
protected void drawableStateChanged ()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

If the View has a StateListAnimator, it will also be called to run necessary state change animations.

Be sure to call through to the superclass when overriding this function.
If you override this method you must call through to the superclass implementation.

onCreateDrawableState

Added in API level 16
protected int[] onCreateDrawableState (int extraSpace)

Generate the new Drawable state for this view. This is called by the view system when the cached Drawable state is determined to be invalid. To retrieve the current state, you should use getDrawableState().

Parameters
extraSpace int: if non-zero, this is the number of extra entries you would like in the returned array in which you can place your own states.
Returns
int[] Returns an array holding the current Drawable state of the view.

onDraw

Added in API level 16
protected void onDraw (Canvas canvas)

Implement this to do your drawing.

Parameters
canvas Canvas: the canvas on which the background will be drawn.
This value cannot be null.

onMeasure

Added in API level 16
protected void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec int: horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec int: vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.

verifyDrawable

Added in API level 16
protected boolean verifyDrawable (Drawable who)

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.

Be sure to call through to the super class when overriding this function.
If you override this method you must call through to the superclass implementation.

Parameters
who Drawable: This value cannot be null.
Returns
boolean boolean If true then the Drawable is being displayed in the view; else false and it is not allowed to animate.