android-recyclerview - 如何在 android 中设置 SimpleExoPlayerView 的最大高度?
问题描述
我正在使用Toro Player(包括 SimpleExoPlayerView)制作一个类似于 Facebook 提要页面的屏幕,我们可以在回收站视图中滚动并自动播放可见视频。我必须根据视频的纵横比设置视频播放器的高度,这是通过使用app:resize_mode="zoom"来实现的。但是有些视频(特别是屏幕录制的)的高度太长,整个手机屏幕都无法覆盖它们。现在我必须为这个视频播放器设置一个最大高度,这样任何视频的高度都只能在用户可见的移动屏幕上进行扩展。这是我的尝试:
这是我的回收站视图的项目布局:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintHeight_max="200dp"
app:layout_constrainedHeight="true"
xmlns:android="http://schemas.android.com/apk/res/android" >
<androidx.cardview.widget.CardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/cardview_light_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/teal_700">
<TextView
android:id="@+id/tvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="10dp"
android:text="Title" />
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
android:id="@+id/player"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tvTitle"
android:minHeight="200dp"
app:resize_mode="zoom"
app:surface_type="texture_view"
app:use_controller="true" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
我尝试过设置最大高度,但总是重复同样的问题。任何建议都会很有帮助。
解决方案
推荐阅读
- asp.net - ora-01002 出于不明显的原因提取乱序
- docker - Rapids / docker:无法选择具有功能的设备驱动程序“”:[[gpu]]
- python - 从 Pandas 列中提取数字信息并将其插入到新列中
- mongodb - mongoose/mongodb 我可以发布但无法获取数据。只返回状态码 500 没有错误
- python - 字段 'id' 需要一个数字,但得到了 'r' - Django 表单
- javascript - 使用不同的数组导航 JSON 文件
- matlab - 计算matlab中连续数字之间包含零的行
- ruby - 通过嵌套数组循环?
- python - 模块脚本中的这些语句实现了什么?
- javascript - 如何影响存储在 localStorage 上的对象值而不覆盖它们?