如果在代码中动态设置了background后padding无效,需要在setBackground后重新设置一次padding
verticalLayout {
backgroundDrawable = getShapeDrawable(ContextCompat.getColor(ctx, R.color.defaultBackground), 2f, 2, ContextCompat.getColor(ctx, R.color.gray_split), 3f, 2f)
padding=dip(15f)
textView {
text = "姓名:"
gravity = Gravity.CENTER_VERTICAL
}.lparams {
width = matchParent
height = dip(20f)
}
textView {
text = "身份证号:"
gravity = Gravity.CENTER_VERTICAL
}.lparams {
width = matchParent
height = dip(20f)
}
textView {
text = "身份证有效期:"
gravity = Gravity.CENTER_VERTICAL
}.lparams {
width = matchParent
height = dip(20f)
}
}.lparams {
gravity = Gravity.CENTER_HORIZONTAL
width = dip(300f)
height = wrapContent
bottomMargin=dip(20f)
}