Problems using Background Gradient in RelativeLayout

19 views
Skip to first unread message

Pete Doherty

unread,
Mar 28, 2015, 4:49:15 AM3/28/15
to clojure...@googlegroups.com
Hi everyone,

How would I set a RelativeLayout's background using a gradient defined in an XML file?

I'm attempting to use:

```
[:relative-layout {
                          :background org.stuff.events.R$drawable/bg_gradient
                       }]
```

However, that results in the following error: `Couldn't find method .setBackground for argument int`

Alexander Yakushev

unread,
Mar 28, 2015, 4:54:44 AM3/28/15
to clojure...@googlegroups.com
http://developer.android.com/reference/android/view/View.html#setBackgroundResource(int)

android:background maps into setBackgroundResource(int) method. There is no :background trait in Neko, so the UI tree compiler falls back to making a setter from a property, which in your example becomes setBackground. So you should write:

[:relative-layout {:background-resource org.stuff.events.R$drawable/bg_gradient}]

Pete Doherty

unread,
Mar 30, 2015, 1:36:47 PM3/30/15
to clojure...@googlegroups.com
OK - that makes sense.

Thanks, Alexander!
Reply all
Reply to author
Forward
0 new messages