Get margin of a View

前端 未结 4 988
遇见更好的自我
遇见更好的自我 2021-01-31 13:28

How can I get the margin value of a View from an Activity? The View can be of any type.

After a bit of searching I found out ways to get padding of a view, but couldn\'

4条回答
  •  梦如初夏
    2021-01-31 13:54

    now use this edited code. this will help you

    FrameLayout.LayoutParams lp=(FrameLayout.LayoutParams)mainLayout.getLayoutParams();
    
    lp.leftMargin  // for left margin
    lp.rightMargin   // for right margin
    

提交回复
热议问题