I have a class which is called when I press a button, the .xml file used as the background is just a black screen. When I run my application I am getting this error:
FATAL EXCEPTION: main
java.lang.NullPointerException
at com.synlight_development.tattoo_it.Menu$2.onClick(Menu.java:71)
at android.view.View.performClick(View.java:2532)
at android.view.View$PerformClick.run(View.java:9293)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4263)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
because of surfaceView default shown on bottom of window.
try this
v.setZOrderOnTop(true); //it puts surfaceview to top of your window.
or also in your SView class set these parameters in constructor etc.
setZOrderOnTop(true);
If you want to use GlSurfaceView. In constructor try this,
setEGLConfigChooser(8,8,8,8,16,0);
getHolder().setFormat(PixelFormat.TRANSLUCENT);
thanks to that your surface view becomes transparent.
if you try put your surfaceView to middlelayer of window it's more harder than this
surfaceView.setZOrderMediaOverlay(true);
and also you seen black screen because your surfaceview needs another surfaceview to get top of. I solved this, i create another surfaceView (Maybe you want to use CameraView etc). and drawn background images, and other surfaceView get top of that, and add another views top of window like that.
1.Layer -> backgroundDrawnSurfaceView
2.Layer (Middle Layer)->myrealSurfaceView
3.Layer -> Another Views.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With