【发布时间】:2021-07-19 05:11:22
【问题描述】:
这是布局的一部分:
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/commentMediaContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<ProgressBar
android:id="@+id/commentMediaLoading"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<VideoView
android:id="@+id/commentMediaVideo"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
还有这个RecyclerView:
holder.commentMediaVideo.setVideoPath(fileUrl)
holder.commentMediaVideo.setOnPreparedListener { mp ->
mp.start()
mp.isLooping = true
holder.commentMediaVideo.requestLayout()
holder.commentMediaContainer.requestLayout()
}
视频与父级匹配,但高度不正确。
如何让 VideoView 以正确的纵横比显示视频?
当我在commentMediaVideo 上尝试wrap_content 而不是0dp 时,视频根本不会显示!
【问题讨论】:
标签: android kotlin android-recyclerview android-videoview