我制作了一个自定义播放器。在exo_simple_player_view.xml
布局中,我设置了自定义组件,在exo_playback_control_view.xml
布局中,有自定义按钮。在activity_player.xml
布局中,播放器本身。但是我的背景也会显示出来。如何制作这种形式的播放器?
exo_simple_player_view.xml
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<com.google.android.exoplayer2.ui.AspectRatioFrameLayout
android:id="@id/exo_content_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<View
android:id="@id/exo_shutter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/side_nav_bar" />
<ImageView
android:id="@id/exo_artwork"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.exoplayer2.ui.SubtitleView
android:id="@id/exo_subtitles"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
<View
android:id="@id/exo_controller_placeholder"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@id/exo_overlay"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</merge>
exo_playback_control_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@id/exo_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:paddingLeft="@dimen/exo_player_padding_left"
android:paddingRight="@dimen/exo_player_padding_right"
android:textSize="@dimen/exo_player_text_size"
android:textStyle="bold" />
<com.google.android.exoplayer2.ui.DefaultTimeBar
android:id="@id/exo_progress"
android:layout_width="0dp"
android:layout_height="@dimen/exo_player_trackbar_height"
android:layout_weight="1" />
<TextView
android:id="@id/exo_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:paddingLeft="@dimen/exo_player_padding_left"
android:paddingRight="@dimen/exo_player_padding_right"
android:textSize="@dimen/exo_player_text_size"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/exo_controls_margin_bottom"
android:gravity="center"
android:orientation="horizontal">
<ImageButton
android:id="@+id/btnPrev"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginRight="0dp" />
<ImageButton
android:id="@id/exo_rew"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone" />
<ImageButton
android:id="@id/exo_play"
android:layout_width="@dimen/exo_player_btn_size"
android:layout_height="@dimen/exo_player_btn_size"
android:layout_marginRight="@dimen/exo_player_margin_right"
android:background="@drawable/icon_play" />
<ImageButton
android:id="@id/exo_pause"
android:layout_width="@dimen/exo_player_btn_size"
android:layout_height="@dimen/exo_player_btn_size"
android:layout_marginRight="@dimen/exo_player_margin_right"
android:background="@drawable/icon_stop" />
<ImageButton
android:id="@id/exo_ffwd"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone" />
<ImageButton
android:id="@+id/btnNext"
android:layout_width="0dp"
android:layout_height="0dp" />
</LinearLayout>
</LinearLayout>
activity_player.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.PlayerActivity">
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
android:id="@+id/player"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/player_bg"
ads:hide_on_touch="false"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintHorizontal_bias="0.0"
ads:layout_constraintLeft_toLeftOf="parent"
ads:layout_constraintRight_toRightOf="parent"
ads:layout_constraintTop_toBottomOf="parent"
ads:show_timeout="0"></com.google.android.exoplayer2.ui.SimpleExoPlayerView>
</RelativeLayout>
如何使这种球员?要有一个圆形的框架,背景不是吗?