tubi_tv_drawable_chromecast_on_selector.xml


Overview

`tubi_tv_drawable_chromecast_on_selector.xml` is an Android **drawable selector resource file** used to define different visual states for the Chromecast "on" button in the Tubi TV application. Specifically, it manages which drawable image is shown depending on the button's pressed state. This allows the UI to provide immediate visual feedback to users when they interact with the Chromecast toggle.


Purpose and Functionality

This selector file enables dynamic switching between two drawable resources:

When the button is pressed, Android automatically swaps the drawable to the pressed image, enhancing UX by providing a tactile response. When released, it reverts to the default drawable.


File Structure and Elements

This XML file uses the [](/projects/288/68408) element as the root, which defines a list of `` elements. Each `` associates a drawable resource with one or more state attributes (`android:state_pressed` in this case).

Elements

Element

Attributes

Description

`xmlns:android`

Root element that declares this XML as a StateListDrawable selector.

``

`android:drawable`

Specifies the drawable resource to use.

[android:state_pressed="true

false"](/projects/288/68333)


Detailed Explanation of Items

Item #

Drawable Resource

State Condition

Usage Description

1

`@drawable/tubi_tv_chromecast_on`

android:state_pressed="false"

Drawable shown when button is not pressed (normal state).

2

`@drawable/tubi_tv_chromecast_on_pressed`

android:state_pressed="true"

Drawable shown when button is pressed.

3

`@drawable/tubi_tv_chromecast_on`

Default (no explicit state)

Fallback drawable if no state matches; acts as a default.


Usage Example

This selector is typically referenced in the layout XML or programmatically set as the background or image source of a button or ImageView.

XML Usage Example

<ImageButton
    android:id="@+id/chromecast_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/tubi_tv_drawable_chromecast_on_selector"
    android:background="@null"
    android:contentDescription="@string/chromecast_button_desc" />

In this example, the `android:src` attribute uses the selector resource, so clicking the button triggers the drawable change based on the pressed state.


Important Implementation Details


Interaction with Other System Components


Diagram: Drawable Selector Workflow

flowchart TD
    A[User taps Chromecast button] --> B{Button state?}
    B -- Pressed --> C[tubi_tv_chromecast_on_pressed drawable displayed]
    B -- Not Pressed --> D[tubi_tv_chromecast_on drawable displayed]
    C --> E[UI shows pressed visual feedback]
    D --> E[UI shows normal visual]

Summary

This file is a simple but essential part of the Tubi TV app’s UI theming and interaction design, contributing to polished and intuitive user controls for Chromecast functionality.