Java 如何在Exoplayer的字幕视图中显示所需位置的文本

Java 如何在Exoplayer的字幕视图中显示所需位置的文本,java,xml,exoplayer,Java,Xml,Exoplayer,我是android studio的新手。我正在尝试自定义exoplayer用户界面,并能够通过以下代码显示播放器视图和播放控件。但subtitle视图中的文本始终位于视图端口的底部。如何将字幕文本放置在所需位置,如字幕视图中的中间或顶部 我尝试使用不同的xml布局,例如限制字幕视图的高度,但字幕视图似乎会占用播放器视图下方的所有空间。我还阅读了subtitle view类文档,以找到实现所需功能的方法,但没有成功。提前感谢您的帮助 <LinearLayout xmlns:android="

我是android studio的新手。我正在尝试自定义exoplayer用户界面,并能够通过以下代码显示播放器视图和播放控件。但subtitle视图中的文本始终位于视图端口的底部。如何将字幕文本放置在所需位置,如字幕视图中的中间或顶部

我尝试使用不同的xml布局,例如限制字幕视图的高度,但字幕视图似乎会占用播放器视图下方的所有空间。我还阅读了subtitle view类文档,以找到实现所需功能的方法,但没有成功。提前感谢您的帮助

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<Button
android:id="@+id/Navigator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Test1"
android:textAllCaps="false" />

<com.google.android.exoplayer2.ui.AspectRatioFrameLayout 
    android:id="@id/exo_content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="top|center">

    <!-- Video surface will be inserted as the first child of the content 
    frame. -->

    <View android:id="@id/exo_shutter"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/black"/>

    <View
        android:id="@id/exo_controller_placeholder"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="visible" />

</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>

<com.google.android.exoplayer2.ui.SubtitleView 
    android:id="@id/exo_subtitles"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white" />

</LinearLayout>

这是emulator上播放器的屏幕截图:


我使用具有字符串值和颜色资源的数组来实现这一点。从某种程度上说,它工作得很好。但我所做的完全是定制的。可能exoplayer有一些默认函数,我是用一个字符串值和颜色资源的数组来实现的。从某种程度上说,它工作得很好。但我所做的完全是定制的。可能是exoplayer有一些默认功能。