tubi_tv_drawable_subtitles_off_selector_tv.xml


Overview

This XML file defines a **state list drawable selector** used in the Tubi TV Android application, specifically for the "subtitles off" button or indicator in the TV user interface. Its primary purpose is to provide different visual feedback (drawables) for various UI states such as pressed, focused, and default, enhancing the user experience by clearly indicating the button's interaction states.

In Android TV applications, where remote navigation is common, focus and press states are crucial for accessibility and usability. This selector ensures that the "subtitles off" icon changes appearance appropriately when the user interacts with it.


Detailed Explanation

What is a State List Drawable Selector?

A **state list drawable** is an XML resource that defines different images (drawables) to display based on the state of the UI element it is attached to. Android automatically switches the image based on the current state of the UI component (e.g., pressed, focused, enabled).

Structure of this File

The root element is ``, which contains multiple `` elements. Each `` specifies:

Android uses the first `` whose states match the current view state.

Items Defined in this Selector

Item Order

Drawable Resource

State Condition

Description

1

`@drawable/tubi_tv_subtitles_off_faded`

android:state_pressed="true"

Drawable shown when the button is pressed.

2

`@drawable/tubi_tv_subtitles_off`

android:state_focused="true"

Drawable shown when the button is focused.

3

`@drawable/tubi_tv_subtitles_off_faded`

`android:state_focused="false"`

Drawable shown when the button is **not** focused (default state).

Usage Example

This selector would be referenced in a layout XML file or programmatically set as the drawable for an `ImageView` or `Button`. For example:

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

Or in a Button background:

<Button
    android:id="@+id/subtitles_off_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/tubi_tv_drawable_subtitles_off_selector_tv" />

When the user navigates to this button or presses it, the icon updates accordingly.


Important Implementation Details


Interaction with Other Parts of the System


Diagram: Component Interaction for Subtitle Off Button Drawable Selector

componentDiagram
    component Selector {
        +state_pressed="true"
        +state_focused="true"
        +state_focused="false"
    }
    component DrawableResources {
        tubi_tv_subtitles_off_faded
        tubi_tv_subtitles_off
    }
    component UIElement {
        ImageView or Button
        Uses selector as src or background
    }

    UIElement --> Selector : uses drawable selector
    Selector --> DrawableResources : references drawable assets

Summary

This simple but essential UI resource enhances the clarity and responsiveness of subtitle toggle controls on Android TV devices, improving overall user experience.