访问Ruboto中的/ res / drawable文件夹

时间:2014-07-09 04:48:46

标签: android ruboto

在我可以在互联网上进行的所有研究之后,似乎访问位于/ res / drawable文件夹中的资源(在我的情况下是.xml布局文件)以返回Drawable就像调用此一样简单行:

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 }

我缺少什么来从该文件夹中获取资源?

1 个答案:

答案 0 :(得分:1)

Ruboto::R::drawable::stroke_bg不是Drawable,而是int资源ID。您必须获取实际资源才能将其用作Drawable。将背景属性更改为以下内容:

background: resources.getDrawable(Ruboto::R::drawable::stroke_bg)

background: resources.getDrawable($package.R.drawable.stroke_bg)

相关问题