This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
forked from sattvik/neko
-
Notifications
You must be signed in to change notification settings - Fork 36
Request for guidance for custom element #50
Comments
I think I found the answer - a :custom-constructor for a View. |
Indeed, I used :custom-constructor attribute to create a proxy where I override onDraw. So did it work for you? |
Yes it did - thanks (defn draw-circle [^Canvas canvas]
(let [paint (Paint. Paint/ANTI_ALIAS_FLAG)]
(.drawCircle canvas 0 0 20 paint)))
(defn main-layout [activity] [:linear-layout {:orientation :horizontal}
[:edit-text {:hint "Event name"}]
(make-ui activity [:view {:custom-constructor
(fn [ctx]
(proxy [android.view.View] [ctx]
(onDraw [^Canvas canvas]
(draw-circle canvas)
)))}])]) |
OK, so I see you called (defn main-layout [activity]
[:linear-layout {:orientation :horizontal}
[:edit-text {:hint "Event name"}]
[:view {:custom-constructor
(fn [ctx]
(proxy [android.view.View] [ctx]
(onDraw [^Canvas canvas]
(draw-circle canvas)
)))}]]) |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi there,
I'm looking to create a custom drawing as part of a component. In the Android API it seems I'd subclass view and implement onDraw to draw directly on the canvas. I'm not sure in neko if it's possible to do this without writing my custom component in Java - it seems custom elements need a classname.
Any pointer much appreciated,
Cheers,
Dean
The text was updated successfully, but these errors were encountered: