程诺陪你学Android

Android 代码中设置控件的边距

2022-05-10  本文已影响0人  sssssss_

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

猜你喜欢

热点阅读