views:

248

answers:

1

Hello there...

I'm using SurfaceView to draw some stuff using canvas. The problem is that I want to show everything horizontally by default and keep it that way regardless the position of the device. I'm not using any layout XML file to show the SurfaceView; instead I just have a class that extends SurfaceView and I do setContentView(new Panel(this)); to show it.

Thanks for your help.

+4  A: 

Your problem is that the activity will want to rotate based on the position of the device or keyboard (depending on which device this is). If you want the activity to ignore rotation, add android:screenOrientation="portrait" or android:screenOrientation="landscape" to your manifest for this activity. You might also want to add android:configChanges="keyboardHidden|orientation" to the activity as well, so Android does not bother destroying and recreating the activity when the user changes orientation.

See here and here for sample projects related to this.

CommonsWare
Thank you so much. It works perfectly :D
Cristian