tubi_tv_drawable_pause_selector.xml
Overview
`tubi_tv_drawable_pause_selector.xml` is an Android **drawable selector** XML resource file used within the Tubi TV application to define the visual states of a media control button, specifically the "pause" button in the video playback interface. This selector enables the button to change its appearance dynamically based on the user's interaction, such as when the button is pressed or released.
By specifying different drawable resources for various states, this XML file helps provide intuitive and responsive UI feedback, enhancing the user experience during media playback controls.
Detailed Explanation
Purpose
This file acts as a state list drawable — a specialized XML resource that selects which drawable to display based on the current state of the UI element (e.g., pressed, focused, default). It is particularly used for the pause/play toggle button, allowing it to switch between "pause" and "play" icons depending on whether the button is being pressed.
Structure and Elements
The root element is ``, which contains multiple `` elements. Each `` specifies:
An Android drawable resource to display (
android:drawable)Optional state conditions (e.g., android:state_pressed="true" or
false)
Items defined in this file:
Item Index | `android:state_pressed` | Drawable Resource | Description |
|---|---|---|---|
1 | false | `@drawable/tubi_tv_pause_large` | Shows the large pause icon when not pressed. |
2 | true | `@drawable/tubi_tv_play_selector` | Shows the play selector icon when pressed. |
3 (default) | (none) | `@drawable/tubi_tv_pause_large` | Default drawable if no states match (pause). |
Usage
This selector XML is typically referenced as the `android:background` or `android:src` attribute of an `ImageButton` or similar UI component in a layout XML file or programmatically in the app’s code.
Example usage in a layout XML:
<ImageButton
android:id="@+id/pause_play_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/tubi_tv_drawable_pause_selector"
android:contentDescription="@string/pause_play_button_desc" />
When the user presses the button, the drawable switches to the play icon, providing visual feedback that pressing the button will toggle playback state.
Implementation Details and Behavior
State Handling:
The selector uses theandroid:state_pressedattribute to detect when the button is pressed (touched).When
state_pressed="true", the drawable changes to the play icon (tubi_tv_play_selector).When
state_pressed="false"or default, the drawable remains the pause icon (tubi_tv_pause_large).
Drawable References:
@drawable/tubi_tv_pause_largeis presumably a static image representing the pause symbol in a large size.@drawable/tubi_tv_play_selectoris likely another selector drawable or image representing the play symbol, possibly with its own states.
Fallback / Default:
The last<item>without a specified state acts as a fallback totubi_tv_pause_largeto ensure a drawable is always displayed.
Interaction with Other System Components
UI Layer:
This file interacts directly with the user interface layouts representing media controls. It enables dynamic state changes in the pause/play button visuals without requiring explicit code to switch images.Media Control Logic:
While this XML controls visual feedback, the actual media playback state changes (play/pause) are handled in the app’s business logic layer (likely in an Activity, Fragment, or ViewModel). The selector complements this by providing appropriate button images corresponding to user interaction.Related Drawables:
tubi_tv_pause_largeandtubi_tv_play_selectordrawables must exist in the project's drawable resources.The
tubi_tv_play_selectordrawable may itself be a selector or animation that further handles play button states.
Summary
Provides visual state switching for the pause/play button based on press state.
Uses Android state list drawable selector pattern.
Depends on two other drawable resources (
tubi_tv_pause_largeandtubi_tv_play_selector).Enhances user experience by visually indicating button press actions.
Works in conjunction with media playback logic and UI layout files.
Visual Diagram
flowchart TD
A[Pause/Play Button UI Component]
A -->|Background Drawable| B(tubi_tv_drawable_pause_selector.xml)
B -->|state_pressed=false| C[tubi_tv_pause_large]
B -->|state_pressed=true| D[tubi_tv_play_selector]
C -->|Static Drawable| E[Pause Icon Image]
D -->|Possibly Selector or Image| F[Play Icon Drawable]
**Diagram Explanation:**
The UI component uses
tubi_tv_drawable_pause_selector.xmlas its background.The selector switches drawable based on
state_pressed:Not pressed → pause icon displayed
Pressed → play icon displayed
Each drawable points to the respective image or another drawable resource used for rendering.
Additional Notes
This file is purely declarative and contains no logic other than state-to-drawable mapping.
For developers extending or modifying this selector: ensure referenced drawable resources exist and match desired visual styles.
If advanced animations or transitions are needed, consider using AnimatedStateListDrawable or programmatic UI updates.