设置SurfaceView的背景图像 [英] Set the Background Image of a SurfaceView

查看:206
本文介绍了设置SurfaceView的背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来设置一个SurfaceView的背景图片?是否必须在XML做或者我可以做这一切在Java中 - 我已经得到的东西,看起来像这样在我的构造函数:

Is there a way to set the background image of a SurfaceView? Does it have to be done in xml or can I do it all in Java - I've got something that looks like this in my constructor:

Drawable sky = (getResources().getDrawable(R.drawable.sky));
    this.setBackgroundDrawable(sky);

但它仍然没有显示任何东西。

But it still doesn't show anything.

推荐答案

您不能设置一个SurfaceView背景绘制。你必须绘制背景在表面上你自己。

You cannot set a background drawable on a SurfaceView. You'll have to draw the background onto the surface yourself.

这篇关于设置SurfaceView的背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆