tubi_tv_drawable_quality_off_selector.xml


Overview

The [tubi_tv_drawable_quality_off_selector.xml](/projects/288/68408) file is an Android **drawable selector resource** used to define different visual states for a UI element related to the "quality off" icon in the Tubi TV app. Specifically, it manages which drawable image should be displayed based on the UI element’s interaction states such as checked or pressed.

This XML selector enables dynamic switching between different graphics depending on user actions, providing visual feedback to improve user experience. It is typically referenced in UI components like `ImageButton`s or `ToggleButton`s to reflect the current state of the button (normal, pressed, or unchecked).


Detailed Explanation

XML Root Element: <selector>


Child Elements: <item>

Each `` element specifies:


Items in This Selector

Item Order

Drawable Resource

State Conditions

Description

1

`@drawable/tubi_tv_quality_off`

`android:state_checked="false"`, [android:state_pressed="false"](/projects/288/68333)

Normal state when the button is unchecked and not pressed.

2

`@drawable/tubi_tv_quality_off_faded`

`android:state_checked="false"`, [android:state_pressed="true"](/projects/288/68333)

Pressed state when the button is unchecked but pressed (user is clicking).

3

`@drawable/tubi_tv_quality_off`

*No state specified* (default)

Default fallback drawable used if no other state matches.


Usage Example

In an Android layout XML, this selector can be applied as the `android:background` or `android:src` of an interactive UI element:

<ToggleButton
    android:id="@+id/quality_off_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:button="@drawable/tubi_tv_drawable_quality_off_selector" />

This way, the button automatically changes its icon based on whether it is pressed or not.


Important Implementation Details


Interaction with Other System Components


Visual Diagram

The following Mermaid flowchart illustrates the decision flow used by Android to select the drawable based on the button state:

flowchart TD
    Start[Start: Button State Evaluation]
    Unchecked_NotPressed{state_checked=false<br>state_pressed=false?}
    Unchecked_Pressed{state_checked=false<br>state_pressed=true?}
    Default[Default Drawable<br>@drawable/tubi_tv_quality_off]

    Start --> Unchecked_NotPressed
    Unchecked_NotPressed -- Yes --> Drawable1[@drawable/tubi_tv_quality_off]
    Unchecked_NotPressed -- No --> Unchecked_Pressed
    Unchecked_Pressed -- Yes --> Drawable2[@drawable/tubi_tv_quality_off_faded]
    Unchecked_Pressed -- No --> Default

Summary

This file is a lightweight yet essential part of the UI layer, enabling dynamic visual feedback for the Tubi TV application’s quality control feature.