图片:https://www.dropbox.com/s/prmw3vb6pugrefy/Untitled.png?dl=0
请访问上面的链接或Click here以查看图片中的整个问题。 由于声誉较低,我无法在此处添加图片。
在此给定图像中,存在两个视图
1:VideoView for Media
2:SurfaceView Camera的FrameLayout
正常工作: 在活动启动时视频(VideoView for media)正在屏幕上正常播放,前置摄像头(FrameLayout用于摄像头)也在右上角使用VideoView 即VideoView中的FrameLayout(在VideoView的右上角)
如果我们点击"按钮"然后frameLayout越来越大,videoview越来越小,反之亦然。 即现在VideoView with FrameLayout(在FrameLayout的右上角)
问题如果点击按钮所有功能正常工作,即VideoView越来越小,FrameLayout越来越大但反之亦然VideoView越来越大,FrameLayout越来越小但现在相机视图不可见。实际上它是VideoView的背景......在这里我无法让它可见。或将FrameLayout置于VideoView之上。
我在这里使用了所有可能的解决方案,但无法解决此问题。
所以任何人都可以帮助让它变得可见?
我还附上了代码请帮助。
.java文件
mVideoView11 = (VideoView)rootview.findViewById(R.id.videoview11);
myCameraPreview = (FrameLayout)rootview.findViewById(R.id.frame_video_camera);
public void onClick(View v) {
if(v == button2){
changeLayout();
}else if(v == button3){
changeLayoutAgain();
}
}
// for large Camera view(FrameLayout)
public void changeLayout(){
RelativeLayout.LayoutParams head_params1 = (RelativeLayout.LayoutParams)mVideoView11.getLayoutParams();
head_params1.setMargins(400, 20, 10, 0);
head_params1.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
head_params1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
head_params1.height=360;
head_params1.width=200;
mVideoView11.setLayoutParams(head_params1);
head_params1 = null;
// Camera view
RelativeLayout.LayoutParams head_params = (RelativeLayout.LayoutParams)myCameraPreview.getLayoutParams();
head_params.setMargins(0, 250, 0, 5);
head_params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
head_params.width=500;
head_params.width = head_params.FILL_PARENT;
myCameraPreview.setLayoutParams(head_params);
head_params = null;
}
// For large VideoView
public void changeLayoutAgain(){
// for large video view
RelativeLayout.LayoutParams head_params1 = (RelativeLayout.LayoutParams)mVideoView11.getLayoutParams();
head_params1.setMargins(0, 250, 0, 5);
head_params1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
head_params1.height=500;
head_params1.width = head_params1.FILL_PARENT;
mVideoView11.setLayoutParams(head_params1);
head_params1 = null;
// Camera view
RelativeLayout.LayoutParams head_params = (RelativeLayout.LayoutParams)myCameraPreview.getLayoutParams();
//head_params.setMargins(500, 20, 5, 5);
head_params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
head_params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
head_params.height=200;
head_params.width=200;
myCameraPreview.setLayoutParams(head_params);
head_params = null;
}
.xml文件
<VideoView
android:id="@+id/videoview11"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:visibility="visible" />
<FrameLayout
android:id="@+id/frame_video_camera"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#ff0000"
android:visibility="visible" >
</FrameLayout>