     (doseq [[attr-name attr-id] (:with-id relative-layout-attributes)]
       (when (contains? attributes attr-name)
         (.addRule lp attr-id (to-id (attr-name attributes)))))
+    (apply-margins-to-layout-params lp attributes)
     (.setLayoutParams wdg lp)))
 
 (deftrait :padding

         (map keys (vals relative-layout-attributes))))

(deftrait :relative-layout-params
  {:attributes all-relative-attributes
   :applies? (= (kw/keyword-by-classname container-type) :relative-layout)}
  [^View wdg, {:keys [layout-width layout-height
                      layout-align-with-parent-if-missing] :as attributes}

   (.setLayoutParams wdg (ViewGroup$LayoutParams. width height))))

(deftrait :linear-layout-params
  "Takes `:layout-width`, `:layout-height`, `:layout-weight`,
  `:layout-gravity` and different layout margin attributes and sets
  LinearLayout.LayoutParams if current container is LinearLayout.
  Values could be either numbers of `:fill` or `:wrap`."
  {:attributes (concat margin-attributes [:layout-width :layout-height
                                          :layout-weight :layout-gravity])
   :applies? (= (kw/keyword-by-classname container-type) :linear-layout)}
  [^View wdg, {:keys [layout-width layout-height layout-weight layout-gravity]
               :as attributes}
   {:keys [container-type]}]
  (let [width  (kw/value :layout-params (or layout-width  :wrap))
        height (kw/value :layout-params (or layout-height :wrap))
        weight (or layout-weight 0)
        params (LinearLayout$LayoutParams. width height weight)]
    (apply-margins-to-layout-params params attributes)
    (when layout-gravity
      (set! (. params gravity)
            (kw/value :layout-params layout-gravity :gravity)))
