View Margin 设置方法记录

2020-01-14  本文已影响0人  啸鳯

已测试

private  void setMargins (View v, int l, int t, int r, int b) {      
        if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
            ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
            params.setMargins(l, t, r, b);
            v.requestLayout();
        }
    }
上一篇 下一篇

猜你喜欢

热点阅读