Mobile video development in the screen conversion encountered bug (Android)

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.