大佬教程收集整理的这篇文章主要介绍了android – 4.1中ScrollView中的SurfaceView,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
很高兴看到它在我的个人开发专用手机(HTC Desire HD 2.3.7)上运行良好,我试着在我公司开发专用手机(谷歌Nexus S 4.1.?)上测试它,然后在我的个人手机上测试(HTC One X 4.1.1).
在最后两个问题上出了点问题,我的SurfaceView在一些~80px滚动之后变成了黑色,然后转回到我在这个~80px下滚动回来的样子(取决于屏幕尺寸).
为了避免这种停电,我在一些模拟器下进行了测试……
从2.2(客户的愿望)到4.0.4,它的效果非常好.
这个笑话是在4.2以下……它也有效!
当然,只有4.1.x才能使SurfaceView变黑!
这是我的SurfaceView代码,我刚刚从您可以找到的样本中复制了here.
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); } } } }
以上是大佬教程为你收集整理的android – 4.1中ScrollView中的SurfaceView全部内容,希望文章能够帮你解决android – 4.1中ScrollView中的SurfaceView所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。