 
 (defn value
   "If the value is a keyword then returns the value for it from the
-keyword-mapping. If the value-keyword isn't present in the
-keyword-mapping, form the value as
-`classname-for-element-kw/CAPITALIZED-VALUE-KW`."
+  keyword-mapping. The value is sought in the element itself and all
+  its parents. If the value-keyword isn't present in any element's
+  keyword-mapping, form the value as
+  `classname-for-element-kw/CAPITALIZED-VALUE-KW`."
   [element-kw value]
-  (if-not (keyword? value)
-    value
-    (get-in @keyword-mapping [element-kw :values value]
-            (keyword->static-field (classname element-kw) value))))
+  (let [mapping @keyword-mapping
+        recursive-find (fn [kw]
+                         (when kw
+                           (or (get-in mapping [kw :values value])
+                               (recur (get-in mapping [kw :inherits])))))]
+    (if-not (keyword? value)
+      value
+      (or (recursive-find element-kw)
+          (keyword->static-field (classname element-kw) value)))))
 
 (defn add-default-atribute-value!
   "Adds a default attribute value for the given element."

(def ^{:private true} keyword-mapping
  (atom
   ;; UI widgets
   {:button {:classname android.widget.Button
             :traits [:layout-params :on-click :def]
             :attributes {:text "Default button"}}
    :linear-layout {:classname android.widget.LinearLayout
                    :traits [:layout-params :def]}
    :edit {:classname android.widget.EditText
           :traits [:layout-params :def]}
    :text-view {:classname android.widget.TextView
                :traits [:layout-params :def]}
    :list-view {:classname android.widget.ListView
                :traits [:layout-params :def]}

    ;; Other
    :layout-params {:classname ViewGroup$LayoutParams

         update-in [element-kw :attributes attribute-kw] value))

(defn default-attributes [element-kw]
  "Returns a map of default attributes for the given element keyword
  and all its parents."
  [element-kw]
  (merge (when element-kw
           (default-attributes (get-in @keyword-mapping
                                       [element-kw :inherits])))
         (get-in @keyword-mapping [element-kw :attributes])))

(defn defelement
  "Defines the element of the given class with the provided name to
  use in the UI construction. Takes the element's classname, a parent
  it inherits, a list of traits and a map of specific values as
  optional arguments.

  Optional arguments
  - :classname, :inherits, :traits, :values, :attributes. "
  [kw-name & args]
  (swap! keyword-mapping assoc kw-name (apply hash-map args)))
