ここに問題があります。パフォーマンス上の理由から、SurfaceViewを使用してテーブルのようなフォームを描画することを選択します。これはデータでいっぱいなので、SurfaceViewの親としてScrollViewを使用します。
個人用開発専用電話(HTC Desire HD 2.3.7)で正常に動作することを確認し、会社開発専用電話(Google Nexus S 4.1。?)のいずれかでテストしてから、個人用電話でテストしてみました。 (HTC One X 4.1.1)。
最後の2つで問題が発生しました。約80ピクセルのスクロールの後、SurfaceViewが黒くなり、この約80ピクセルの下でスクロールして戻ったときの外観に戻りました(画面サイズによって異なります)。
この停電を回避するために、いくつかのエミュレーターでテストしました...
2.2(顧客の希望)から4.0.4まで、それはちょうど素晴らしい働きをします。
冗談は、4.2の下で...それも機能します!
間違いなく、SurfaceViewが黒くなるのは4.1.x未満です。
これが私のSurfaceViewコードで、ここにあるサンプルからコピーしたものです。
public class MySurfaceView extends SurfaceView
{
public MySurfaceView(Context context, AttributeSet attrs)
{
super(context, attrs);
// I use another SurfaceView behind to draw a grid
// that is scroll independent with a white background
this.setZOrderOnTop(true);
// Same reason here
this.getHolder().setFormat(PixelFormat.TRANSPARENT);
this.getHolder().addCallback(this);
this.getHolder().setSizeFromLayout();
// Tried without this line and with "software" and "none" types too
// and hardware acceleration on application and activity
this.setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
canvas.drawSomething()...
}
public void surfaceCreated(SurfaceHolder holder)
{
this.setWillNotDraw(false);
this.thread = new MySurfaceViewThread(this.getHolder(), this);
this.thread.setRunning(true);
this.thread.run();
}
public void surfaceDestroyed(SurfaceHolder holder)
{
this.thread.setRunning(false);
boolean retry = true;
while(retry)
{
try
{
this.thread.join();
retry = false;
}
catch(Exception exception)
{
Log.v(TAG, exception.getClass().getName(), exception);
}
}
}
}