title: Get margin of a View
body: <p>How can I get the margin value of a View from an Activity? The View can be of any type. </p>
  
  <p>After a bit of searching I found out ways to get padding of a view, but couldn't find anything on Margin. Can anyone help?</p>
  
  <p>I tried something like this,</p>
  
  <pre><code>ViewGroup.LayoutParams vlp = view.getLayoutParams();
  int marginBottom = ((LinearLayout.LayoutParams) vlp).bottomMargin;
  </code></pre>
  
  <p>This works, but in the above code I have assumed the view to be a <code>LinearLayout</code>. But I need to get the <code>margin</code> attribute even when I don't know the view type.</p>