gpt4 book ai didi

mediacontroller not anchored to video frame layout(媒体控制器未固定到视频帧布局)

转载 作者:bug小助手 更新时间:2023-10-25 17:58:46 25 4
gpt4 key购买 nike



I'm trying to view videos in my app, but the problem is that the media controller doesn't stay docked to the video. In fact, if I scroll down the page, the media controller of the first video is located on the buttons

我尝试在应用中查看视频,但问题是媒体控制器无法停靠在视频上。事实上,如果我向下滚动页面,第一个视频的媒体控制器位于按钮上


enter image description here


the code of the adapter is this:

适配器的代码如下:


public void onBindViewHolder(@NonNull VideoViewHolder holder, int position) {
String videoURL = videoURLs.get(position);

VideoView videoView = holder.videoView;
FrameLayout customMediaController = holder.customMediaController;

// crea un mediaController personalizzato
MediaController mediaController = new MediaController(holder.itemView.getContext());
// collega la VideoView al MediaController
mediaController.setAnchorView(videoView);
// imposta il MediaController per la VideoView
videoView.setMediaController(mediaController);

// gestione manuale della posizione del MediaController
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT
);
layoutParams.gravity = Gravity.CENTER;
customMediaController.setLayoutParams(layoutParams);

.......
}

the code of the xml file is this:

该XML文件的代码如下:


<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">

<!-- Pulsante Play -->
<Button
android:id="@+id/playButton"
android:layout_width="@dimen/larghezza_bottone_piccolo"
android:layout_height="@dimen/altezza_bottone_piccolo"
android:text="@string/avvia"
android:layout_marginTop="3dp"
android:layout_marginStart="50dp" />

<FrameLayout
android:id="@+id/video_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:layout_below="@+id/playButton">

<VideoView
android:id="@+id/videoView"
android:layout_width="300dp"
android:layout_height="300dp"
/>

<FrameLayout
android:id="@+id/custom_media_controller"
android:layout_width="300dp"
android:layout_height="300dp">
</FrameLayout>
</FrameLayout>

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/deleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/delete_icon"
android:contentDescription="@string/elimina"
android:layout_marginTop="3dp"
android:layout_marginStart="20dp"
android:layout_toRightOf="@+id/playButton"/>

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/downloadButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/baseline_download_24"
android:contentDescription="@string/download"
android:layout_marginTop="3dp"
android:layout_toRightOf="@+id/deleteButton"
android:layout_marginStart="20dp" />

</RelativeLayout>

I can't solve this problem, i've tried so many things

我解决不了这个问题,我试了太多办法了


更多回答
优秀答案推荐
更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com