If someone (like me) still has a problem with the sliding menu and background image, I am trying to explain how I am fixing this problem. @Netis's solution did not help me. As you know, the problem will disappear if you do not use the background in the slide menu, so we need to use something else instead of the standard Android background. For this I use TextureView . In my xml menu, I added:
<TextureView android:id="@+id/menu_texture_view" android:layout_width="match_parent" android:layout_height="match_parent" />
In the activity code when adding the initialization menu:
final TextureView texture = (TextureView) menuView.findViewById(R.id.menu_texture_view); final Drawable picture = getResources().getDrawable(R.drawable.menu_background); texture.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() { @Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { Canvas canvas = texture.lockCanvas(); picture.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); picture.draw(canvas); texture.unlockCanvasAndPost(canvas); } @Override public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { } @Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { return false; } @Override public void onSurfaceTextureUpdated(SurfaceTexture surface) { } });
We basically put our background in a TextureView instead of using standard android paths ( android:background , imageVew , etc.).
Also, as a recommendation, you need to add backgrounds for all dpi (mdpi, hpdi, ...) for better performance.
I know this ugly solution, but it works for me when nothing else helped ...
source share