Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View.LAYER_TYPE_HARDWARE cause SurfaceView becomes transparent in 5.0 devices #747

Open
codezjx opened this issue Jan 26, 2016 · 1 comment

Comments

@codezjx
Copy link

codezjx commented Jan 26, 2016

I faced a problem when content view with SurfaceView becomes transparent while sliding, just appear in 5.0 devices. (Samsung SM-P550 & Moto X Pro)

Finally I see a log output in logcat when issue coming:

V/SlidingMenu: changing layerType. hardware? true

This log output contains in SlidingMenu.java:

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public void manageLayers(float percentOpen) {
        if (Build.VERSION.SDK_INT < 11) return;

        boolean layer = percentOpen > 0.0f && percentOpen < 1.0f;
        final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;

        if (layerType != getContent().getLayerType()) {
            getHandler().post(new Runnable() {
                public void run() {
                    Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE));
                    getContent().setLayerType(layerType, null);
                    getMenu().setLayerType(layerType, null);
                    if (getSecondaryMenu() != null) {
                        getSecondaryMenu().setLayerType(layerType, null);
                    }
                }
            });
        }
    }

When sliding start, this code will call setLayerType(View.LAYER_TYPE_HARDWARE, null), and SurfaceView becomes transparent.

Why this will appear, and how to fix?

@codezjx
Copy link
Author

codezjx commented Jan 26, 2016

And I find a similar issue here: SimonVT/android-menudrawer#13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant