Skip to content Skip to sidebar Skip to footer

Android: Flash Content Breaks Webview Boundings And Overlaps Native Layout Elements

I'm using a WebView to display a web page which contains some Flash content which basically works pretty well. The big problem is, that the Flash content seems not to consider the

Solution 1:

I had the same issue with flash. What I found out is that flash view is added with setZOrderOnTop set to true. It causes that flash is rendered on top of all windows (e.g. covers other native layout elements).

I had my own WebView class and I overridden addView methods. When WebView adds any view I check if it is a flash view (by checking "com.adobe.flashplayer.FlashPaintSurface"). If it is I set Z order to false:

@Override
public void addView(View child, int index)
{
    if (child.getClass().getName().equals("com.adobe.flashplayer.FlashPaintSurface"))
    {
        ((SurfaceView)child).setZOrderOnTop(false);
    }

    super.addView(child, index);
}

I do it for every addView method. It works for me and I thought that I will share it.

Solution 2:

I found this (6 month old) android bug report: http://code.google.com/p/android/issues/detail?id=8938 Unfortunately there are so far no solutions, workarounds or comments.

In Adobe's bug tracker I found a similar bug (https://bugs.adobe.com/jira/browse/FP-4684) with the following comment:

The behavior you're describing is a known issue in Flash Player 10.1 on the Android platform. Today, Flash will always display on top of HTML content. Also, when two pieces of Flash content are overlapping, the order in which they are rendered is unpredictable.

This fix for this issue will require updates from both the Android and Flash Player teams, and will be addressed in a future release.

Solution 3:

I ran into this issue today. I was testing on 2.3.6 with some older embedded flash. I liked pzyho's solution as a quick fix but I didn't want to extend WebView and have to make significant changes to existing code. A faster solution was to use setOnHierarchyChangeListener for any given WebView.

myWebView.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {  
        @Override
        public void onChildViewRemoved(View parent, View child) {}
        @Override
        public void onChildViewAdded(View parent, View child) {
            if(child.getClass().getName().equals("com.adobe.flashplayer.FlashPaintSurface"))
                ((SurfaceView)child).setZOrderOnTop(false); 
        }
});

Solution 4:

If it is possible to abstain from the Flash content you can just use the Websettings to disable plugin support.

    webView = (WebView) findViewById(R.id.webview);
    WebSettingssettings= webView.getSettings();
    // deprecated only for API < 8
    settings.setPluginsEnabled(false);
    // for API > 8 recommended
    settings.setPluginState(PluginState.OFF);

If this code doesn't disable the flash plugin and you want to run your App vor API < 8 just delete...

   settings.setPluginsEnabled(true);

...if your are using it in your Websettings without setting the bool to false - that has worked for me! I know that this approach isn't always a solution, but in my case it worked, because the flash content was just an unimportant banner.

Post a Comment for "Android: Flash Content Breaks Webview Boundings And Overlaps Native Layout Elements"