I have a game app with the following Views structure. First I have an empty FrameLayout like so:
FrameLayout game_frame_layout = new FrameLayout(getApplicationContext());
Then I add two views to it like so:
game_frame_layout.addView(customView);
game_frame_layout.addView(butView);
The customView is for displaying all sorts of moving game graphics while the butView displays some ImageButtons on top of the moving grapics. The customView is an instance of a class CustomView which extends SurfaceView.
CustomView includes the following code
void updateView()
{
final SurfaceHolder holder = getHolder();
holder.setFormat(PixelFormat.RGBA_8888);
try
{
Canvas canvas = holder.lockCanvas();
if (canvas != null)
{
onDraw(canvas);
holder.unlockCanvasAndPost(canvas);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
The line holder.setFormat(PixelFormat.RGBA_8888);
is a recent addition (see here). Without that line, my animated graphics appear to be in a format with too few colours (by experiment I deduced it was "RGB_565"), so I get some banding artifacts. When I added the setFormat line, the graphics appear perfectly (without banding) on my Samsung Galaxy Tab 10.1 (Android 3.1)... but on three other devices: a Samsung GT-l9100 (4.1.2), a Nexus 7 ME370T 4.4.2 and a HTC One X 4.2.2 I only see the buttons corresponding to butView against an entirely black background. There is no indication in the logs that the program has crashed.
Any ideas?