tubi_tv_drawable_chromecast_off_selector.xml


Overview

`tubi_tv_drawable_chromecast_off_selector.xml` is an Android drawable selector resource file used to define different drawable (image) states for a Chromecast "off" button in the Tubi TV app. This file manages the visual representation of the Chromecast off button depending on its interaction state — specifically, whether the button is pressed or not.

By leveraging Android's selector mechanism, the app dynamically switches between different drawable assets to provide visual feedback to the user, improving usability and responsiveness of the UI component.


Detailed Explanation

Purpose

Structure and Elements

The root element is ``, which is a state list drawable container. It contains multiple `` elements, each specifying a drawable resource and the state conditions under which it should be used.

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/tubi_tv_chromecast_off" android:state_pressed="false"></item>
    <item android:drawable="@drawable/tubi_tv_chromecast_off_pressed" android:state_pressed="true"></item>
    <item android:drawable="@drawable/tubi_tv_chromecast_off" />
</selector>

<selector>


<item>

Each `` defines a drawable resource and an optional set of state attributes that dictate when this item is selected.

Items in this file:

Index

Drawable Resource

State Condition

Description

1

`@drawable/tubi_tv_chromecast_off`

`android:state_pressed="false"`

Drawable shown when the button is not pressed.

2

`@drawable/tubi_tv_chromecast_off_pressed`

`android:state_pressed="true"`

Drawable shown when the button is pressed.

3

`@drawable/tubi_tv_chromecast_off`

(default)

Fallback drawable if no state matches.


Parameters and Attributes

Attribute

Description

`android:drawable`

Reference to the drawable resource (an image or XML drawable).

`android:state_pressed`

Boolean indicating whether the item applies when the button is pressed (`true`) or not (`false`).


Usage Example

To use this selector in an Android layout XML or programmatically, assign it as the `android:background` or `android:src` of a view, such as an `ImageView` or `Button`.

**In layout XML:**

<ImageView
    android:id="@+id/chromecast_off_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/tubi_tv_drawable_chromecast_off_selector" />

This will automatically switch the image displayed in the `ImageView` between the pressed and unpressed state drawables based on user interaction.

**Programmatically (in Kotlin):**

val chromecastButton: ImageView = findViewById(R.id.chromecast_off_button)
chromecastButton.setImageResource(R.drawable.tubi_tv_drawable_chromecast_off_selector)

Implementation Details


Interaction with Other Parts of the System


Visual Diagram

flowchart TD
    A[Chromecast Off Button View] -->|uses drawable| B[tubi_tv_drawable_chromecast_off_selector.xml]
    B -->|state_pressed=false| C[tubi_tv_chromecast_off (drawable)]
    B -->|state_pressed=true| D[tubi_tv_chromecast_off_pressed (drawable)]
    B -->|default fallback| C

**Diagram explanation:**


Summary

This file is a small but crucial part of the Tubi TV app's UI resource management, enabling dynamic and interactive button visuals without additional code.