根据我在互联网上可以做的所有研究,似乎访问位于/res/drawable文件夹中的资源(在我的例子中是.xml布局文件)来返回可绘制的资源,就像调用这一行一样简单:
Ruboto::R::drawable::stroke_bg但是,当我尝试这样做时,我收到了以下错误:
could not coerce Fixnum to class android.graphics.drawable.Drawable我的观点是:
scroll_view :background => Ruboto::R::drawable::stroke_bg, :layout => { :width => :match_parent, height: 1000 }我遗漏了什么来从那个文件夹中获取资源?
发布于 2014-07-09 23:01:04
Ruboto::R::drawable::stroke_bg不是可绘制的,而是一个int资源ID。您必须获得实际的资源才能将它用作可绘制的。将背景属性更改为如下所示:
background: resources.getDrawable(Ruboto::R::drawable::stroke_bg)
或
background: resources.getDrawable($package.R.drawable.stroke_bg)
https://stackoverflow.com/questions/24645600
复制相似问题