ViewUtils.kt 494 Bytes
Newer Older
1
package com.ydl.ydlcommon.utils
konghaorui committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

import android.view.View
import android.view.ViewGroup

/**
 * view 工具类
 * Created by harvie on 2017/10/27 0027.
 */
object ViewUtils{

    fun setMargins (v : View, l:Int, t : Int, r : Int, b : Int) {
        if (v.getLayoutParams() is ViewGroup.MarginLayoutParams) {
            var p: ViewGroup.MarginLayoutParams = v.getLayoutParams() as ViewGroup.MarginLayoutParams
            p.setMargins(l, t, r, b)
            v.requestLayout()
        }
    }
}