我用两个videoview显示两个视频,为什么会重叠在一起了

小林望北 2014-05-16 02:16:01
我用两个videoview显示两个视频,为什么会重叠在一起了?如图:



		Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ "/001.mp4");
MyVideoView videoView = (MyVideoView) this.findViewById(R.id.videoView1);
videoView.setVideoURI(uri);
videoView.start();

MyVideoView videoView2 = (MyVideoView) this.findViewById(R.id.videoView2);
videoView2.setVideoURI(uri);
videoView2.start();



<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:orientation="vertical"
android:layout_marginLeft="50dp"
android:layout_marginTop="50dp"
android:background="#E820D4"
>
<com.example.test.MyVideoView
android:id="@+id/videoView1"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginLeft="0dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:orientation="vertical"
android:layout_marginLeft="300dp"
android:layout_marginTop="50dp"
android:background="#20E827"
>
<com.example.test.MyVideoView
android:id="@+id/videoView2"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginLeft="0dp"
/>
</LinearLayout>
</FrameLayout>
...全文
183 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
小林望北 2014-05-16
  • 打赏
  • 举报
回复
public class MyVideoView extends VideoView {

	public MyVideoView(Context context) {
		super(context);
	}

	public MyVideoView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public MyVideoView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		int width = 700;
		int height = 400;
        setMeasuredDimension(width, height);
	}

}

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧