tubi_tv_drawable_subtitles_on_selector.xml


Overview

`tubi_tv_drawable_subtitles_on_selector.xml` is an Android drawable selector resource file. Its primary purpose is to define different drawable images for a UI element representing the "subtitles on" state in the Tubi TV application, specifically changing the visual appearance of the subtitle icon based on the element's pressed state.

This XML file enables dynamic UI feedback by switching between two drawable resources when the user interacts with the subtitles toggle button or icon. It improves user experience by visually indicating the press state with a faded version of the subtitle icon.


Detailed Explanation

Root Element: <selector>

Child Elements: <item>

Each `` tag inside the `` specifies a drawable resource and the state conditions under which it should be applied.

Item

Attributes

Description

1

`android:drawable="@drawable/tubi_tv_subtitles_on"`
[android:state_pressed="false"](/projects/288/68333)

Drawable for the subtitles icon when the button is **not pressed**. This is the default visual state when the user is not interacting with the button.

2

`android:drawable="@drawable/tubi_tv_subtitles_on_faded"`
[android:state_pressed="true"](/projects/288/68333)

Drawable for the subtitles icon when the button **is pressed**. This faded image visually indicates a pressed or active interaction state.

3

`android:drawable="@drawable/tubi_tv_subtitles_on"`

Default drawable (fallback), used if no other state matches. Ensures the icon is displayed even if the state is undefined.


Usage

This selector is typically referenced in a layout XML or programmatically in code to set the background or image drawable of a UI component such as an `ImageButton`, `ToggleButton`, or `ImageView` that controls subtitle toggling.

Example in Layout XML:

<ImageButton
    android:id="@+id/subtitles_toggle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/tubi_tv_drawable_subtitles_on_selector"
    android:contentDescription="@string/subtitles_toggle_desc"/>

Behavior:


Important Implementation Details


Interaction with Other Parts of the System


Visual Diagram

The following **Mermaid flowchart** illustrates the state-based flow of drawable selection within this selector file:

flowchart TD
    A[Start: Subtitle toggle button state] --> B{Is button pressed?}
    B -- Yes --> C[tubi_tv_subtitles_on_faded drawable]
    B -- No --> D[tubi_tv_subtitles_on drawable]
    C --> E[Display faded subtitle icon]
    D --> F[Display normal subtitle icon]
    E --> G[End]
    F --> G

Summary

`tubi_tv_drawable_subtitles_on_selector.xml` is a simple yet effective resource that controls the subtitle icon's appearance based on user interaction. It improves the user experience by providing immediate visual feedback when toggling subtitles on the Tubi TV app. It is a reusable component that interacts closely with drawable assets and UI controls in the application’s interface layer.


If you need to modify the behavior (e.g., add more states such as focused or disabled), you can extend this selector by adding more `` elements with appropriate state attributes and drawable references.