tubi_tv_drawable_play_selector_tv.xml


Overview

The [tubi_tv_drawable_play_selector_tv.xml](/projects/288/68396) file is an Android **drawable selector resource** used to define different visual states for a UI component—specifically, the "Play" button in the Tubi TV application for TV devices. This XML file enables the app to display different drawable images depending on the button's interaction state (pressed, focused, or default).

In Android TV apps, where remote control navigation replaces touch input, visual focus and pressed states provide key UX feedback to the user. This selector manages these states visually by specifying which drawable resource to display for each state.


Detailed Explanation

File Type and Purpose

XML Structure

The root element is ``, which contains multiple `` elements. Each `` specifies a drawable resource and an associated state condition.

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

Explanation of Each <item> Element

Item No.

Attributes

Description

Drawable Resource

1

`android:state_pressed="true"`

When the button is pressed (e.g., user clicks or taps), show this drawable.

`@drawable/tubi_tv_play_large_pressed`

2

`android:state_focused="true"`

When the button has focus (e.g., navigated by remote control but not pressed), show this drawable.

`@drawable/tubi_tv_play_large`

3

`android:state_focused="false"`

When the button does not have focus, show this drawable (serves as default/fallback state).

`@drawable/tubi_tv_play_large_pressed`


Key Points and Behavior


Usage Example

This drawable selector is typically referenced in a layout XML file or programmatically assigned to a UI element such as an `ImageButton` or `ImageView` in the Android TV app.

<ImageButton
    android:id="@+id/play_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/tubi_tv_drawable_play_selector_tv"
    android:contentDescription="@string/play_button_desc" />

Implementation Details


Interaction with Other Components


Visual Diagram

flowchart TD
    A[User Interaction]
    A -->|Press Button| B(state_pressed = true)
    A -->|Focus Button| C(state_focused = true)
    A -->|No Focus| D(state_focused = false)

    B -->|Show Drawable| E[tubi_tv_play_large_pressed]
    C -->|Show Drawable| F[tubi_tv_play_large]
    D -->|Show Drawable| E

    style E fill:#f9f,stroke:#333,stroke-width:1px
    style F fill:#bbf,stroke:#333,stroke-width:1px

Summary


If you need to customize the play button's visual feedback or add new states (e.g., disabled), you can extend this selector by adding more `` elements with corresponding state attributes and drawable resources.