Plot Cushion: first of all affirm that I am an android beginner. At first we wanted to make a video call software and soon found the anychat. But at that time with the official website of the demo, only support horizontal screen. We want to achieve the effect of the screen is supported.
problems encountered
1, their video will be blocked by the other's video
2, their own video ratio is not correct
3, your own video will block the volume bar
4, your own video can not be centered
handling of Issue 1
try 1: Because more familiar with the knowledge of the Web, the first thought of using Z-index to control the stack of view, the results of the tragedy did not find z-index analogues
try 2:android, the XML will overwrite the top of the row, but this does not work
Try 3:surfaceview is a special view, which is displayed by default under Normal view, via Myview.setzorderontop (true); can be set Surfaceview to the top level
Problem Solving!
handling of Issue 2
This relatively simple, direct code:
private void adjuestvideosize (int width, int height, Configuration config) {
Configentity configentity = Configservice.loadconfig (this);
float rwidth = configentity.resolution_width;
float rheight = configentity.resolution_height;
if (config.orientation = = configuration.orientation_portrait) {
Rwidth = Configentity.resolution_height;
Rheight = Configentity.resolution_width;
}
if (rheight * width > rwidth * height) {
Dwlocalvideoheight = height;
Dwlocalvideowidth = (int) (rwidth/rheight * dwlocalvideoheight);
} else {
Dwlocalvideowidth = width;
Dwlocalvideoheight = (int) (rheight/rwidth * dwlocalvideowidth);
}
Framelayout.layoutparams layoutparamself=new framelayout.layoutparams (Dwlocalvideowidth, dwLocalVideoHeight);
Myview.setlayoutparams (layoutparamself);
}
Android Device configuration information is placed in the Configentity class, including the camera's resolution
handling of Issue 3
after the first problem is processed, the volume bar is blocked by Surfaceview because of a problem with the UI layout
just set the framelayout outside the Surfaceview
android:layout_height= "0dip"
android:layout_weight= "1"
Description: Weight refers to the weight of the remaining space, so the height of the framelayout is 0+ the remainder of the 100%, will not cover the volume bar of the Section
handling of Issue 4
Surfaceview External framelayout setting properties:android:layout_gravity= "center"
but each time it's the upper-left corner aligned
The fact is that the alignment is changed when the following sentence is executed
framelayout.layoutparams layoutparamself=new framelayout.layoutparams (Dwlocalvideowidth, dwLocalVideoHeight);
Add a parameter and you're OK.Gravity.center
framelayout.layoutparams layoutparamself=new framelayout.layoutparams (dwlocalvideowidth, DwLocalVideoHeight, Gravity.center);
acknowledgements
Finally thanks to Anychat developers, in my process of dealing with the problem of a lot of help, if you need to also can go to their official website download Damo free test ha www.anychat.cn