【发布时间】:2014-09-08 09:46:24
【问题描述】:
我在我的代码中使用 VideoView 从 URL 播放一些视频。我的 VideoView 位于 ScrollView 内的线性布局内。
我的 MediaController 对象出现问题,它出现在视频视图底部,而不是位于 scrollView 内的其他视图和屏幕中的恒定位置(我的意思是当向下滚动屏幕时,所有视图都会移动,除了这个)
我想将此 MediaController 设置在 videoView 下面的常量位置,该位置随滚动条移动。
我的 XML 代码在这里:
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="94dp"
android:layout_marginTop="196dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<AbsoluteLayout
android:id="@+id/nonVideoLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/playerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.HRDatis.component.VideoViewQmery
android:id="@+id/playerImage"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
这里还有JAVA代码:
((LinearLayout)(findViewById(R.id.playerLayout))).setLayoutParams(new LayoutParams((int)(width) , (int)(height*0.371) ,0 , (int)(height*(0.0)) ));
VideoViewQmery videoView =((VideoViewQmery)(findViewById(R.id.playerImage)));
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setVideoURI(Uri.parse(URI));
videoView.setMediaController(mediaController);
请注意,在 onCreate 函数的活动中在 java 中设置的所有维度。此外,我对 mediaController 使用了 setLayoutparam 函数,但它不起作用,并且 mediaController 没有移动。只有 SetY 和 SetX 有效。此功能移动与 VideoView 相关的 MediaController 并没有解决我的问题(我的意思是 MediaController 没有随 Scroll 移动)。 提前致谢。
【问题讨论】:
标签: java android android-layout scrollview android-videoview