tubi_tv_drawable_subtitles_off_selector.xml
Overview
`tubi_tv_drawable_subtitles_off_selector.xml` is an Android **drawable selector resource** file that defines a state-dependent image for a UI component, specifically for a "subtitles off" button or icon within the Tubi TV application. Its primary purpose is to specify different drawable resources to display based on the button's interaction state (e.g., pressed or not pressed). This enhances user experience by providing visual feedback when interacting with the subtitles toggle control.
Detailed Explanation
File Type and Location
Type: Android Drawable Selector XML
Location: Typically placed in the res/drawable or
res/drawable-...resource directories of an Android project.Role: Defines how the drawable (image) changes based on the component's UI state.
XML Structure
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/tubi_tv_subtitles_off" android:state_pressed="false"></item>
<item android:drawable="@drawable/tubi_tv_subtitles_off_faded" android:state_pressed="true"></item>
<!-- default -->
<item android:drawable="@drawable/tubi_tv_subtitles_off" />
</selector>
Elements:
<selector>: Root element defining the drawable selector.<item>: Defines a drawable resource associated with a particular state or default.
States and Drawable Mapping
State Condition | Drawable Resource | Description |
|---|---|---|
`android:state_pressed="false"` | `@drawable/tubi_tv_subtitles_off` | Default appearance when the button is not pressed |
`android:state_pressed="true"` | `@drawable/tubi_tv_subtitles_off_faded` | Appearance when the button is pressed (touched) |
(No state specified) | `@drawable/tubi_tv_subtitles_off` | Fallback/default drawable for any other state |
Usage
This selector file can be used as the `android:background` or `android:src` attribute for a Button, ImageButton, or ImageView in layout XML or programmatically. When the user presses the button, the drawable switches to a faded version to indicate interaction.
**Example usage in a layout XML:**
<ImageButton
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"
android:contentDescription="@string/subtitles_off_description" />
Important Implementation Details
State Handling: This selector only distinguishes between pressed and non-pressed states.
Drawable Resources:
tubi_tv_subtitles_off: Presumably a normal icon representing subtitles turned off.tubi_tv_subtitles_off_faded: A visually "faded" or "dimmed" version used to give visual feedback on press.
Default Fallback: The last
<item>ensures that if no states match, the default drawable is shown, preventing drawable resolution errors.No Other States: Unlike more complex selectors, this file does not handle other states such as
focused,selected, ordisabled.
Interaction with the System / Application
This selector is part of the UI layer of the Tubi TV app.
It interacts with:
UI components (Buttons or ImageButtons) to visually represent the subtitles off state.
Drawable resources which are the actual images displayed.
It contributes to user interaction feedback by changing the drawable on press.
It is likely referenced in the video player UI where users toggle subtitles on/off.
Changes here affect how the subtitles-off control looks and behaves visually in response to touch.
Visual Diagram
flowchart TD
A[UI Component<br/>(Button/ImageButton)] -->|Uses| B[tubi_tv_drawable_subtitles_off_selector.xml]
B --> C[tubi_tv_subtitles_off<br/>(Drawable Resource)]
B --> D[tubi_tv_subtitles_off_faded<br/>(Drawable Resource)]
subgraph State Handling
direction LR
S1[Pressed = false] -->|Shows| C
S2[Pressed = true] -->|Shows| D
S3[Default] -->|Shows| C
end
Summary
tubi_tv_drawable_subtitles_off_selector.xmlis a simple but essential Android drawable selector resource that defines visual feedback for a subtitles off UI control.It varies the drawable based on press state, improving user experience.
It works by mapping UI states to specific drawable resources.
This file plugs into the app's UI layer and uses predefined drawable assets to present state-dependent icons.
The design is straightforward and focused solely on pressed/not pressed states, ensuring reliable and predictable UI behavior.
*End of documentation for* `tubi_tv_drawable_subtitles_off_selector.xml`