You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SimpleExoPlayerView定制:设置背景透明及控件始终可见

Fixing SimpleExoPlayerView Background & Visibility Issues

Hey there! Let's sort out those two customization needs for your ExoPlayer setup. Here's how to address each one clearly:

1. Change the Background to Transparent

You can update this either directly in your XML layout or programmatically in your code:

Option 1: XML Layout Modification

Just add the android:background attribute to your SimpleExoPlayerView and set it to transparent. Here's your updated layout code:

<com.google.android.exoplayer2.ui.SimpleExoPlayerView
    android:id="@+id/video_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent" />

Option 2: Programmatic Setup

If you prefer setting it in code (maybe for dynamic changes), use this line after initializing your SimpleExoPlayerView:

// Assuming you've initialized your player view like this:
SimpleExoPlayerView playerView = findViewById(R.id.video_view);
playerView.setBackgroundColor(Color.TRANSPARENT);

Don't forget to import android.graphics.Color if you go this route.

2. Keep the Player Controls Always Visible

By default, SimpleExoPlayerView hides its controls after a short period of inactivity. To disable this auto-hide behavior and keep controls visible at all times, use these two methods:

// Disable auto-hide when the user touches the screen
playerView.setControllerHideOnTouch(false);
// Set timeout to 0 so controls never automatically hide
playerView.setControllerShowTimeoutMs(0);

Alternatively, you can also explicitly force controls to stay visible with:

playerView.setShowControls(true);

Combining these ensures your player interface stays visible without requiring user touches to bring it back.


内容的提问来源于stack exchange,提问作者Sophie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:26:15