Android Surfaceview black screen

Source: Internet
Author: User

Recently in doing a Viewpager + fragment switch page, one of the fragment to open the camera, need to surfaceview, but when switching to the fragment of the former, this fragment is also loaded. Cause the card and flash a black screen.

Black screen Resolution:

The OnCreate method in the main fragmentacivity

GetWindow (). SetFormat (pixelformat.translucent);

Slow Load method

The Viewpager mechanism is that when a view is loaded, the previous one is retained, the current view is displayed, the pre-loaded view is present, and if the latter view is a more time-consuming page, it causes the comparison card to be displayed.

Resolved in

Fragment's

@Override
public void Setuservisiblehint (Boolean isvisibletouser) {

Super.setuservisiblehint (Isvisibletouser);

True when current fragment is displayed, not displayed as false

if (Isvisibletouser) {

Loading data

}


}

Android Surfaceview black screen

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.