fix: bugfix
This commit is contained in:
@@ -27,24 +27,28 @@ import java.util.Locale
|
||||
|
||||
|
||||
fun View.setMargin(start:Int?=null,top:Int?=null,end:Int?=null,bottom:Int?=null,isDP:Boolean = true) {
|
||||
val lp = this.layoutParams as MarginLayoutParams
|
||||
if (this.layoutParams != null) {
|
||||
val lp = this.layoutParams
|
||||
if (lp is MarginLayoutParams){
|
||||
if (start != null) {
|
||||
lp.marginStart = if (isDP)SizeUtils.dp2px(this.context,start.toFloat()) else start
|
||||
}
|
||||
|
||||
if (start != null) {
|
||||
lp.marginStart = if (isDP)SizeUtils.dp2px(this.context,start.toFloat()) else start
|
||||
if (top != null) {
|
||||
lp.topMargin = if (isDP)SizeUtils.dp2px(this.context,top.toFloat()) else top
|
||||
}
|
||||
|
||||
if (end != null) {
|
||||
lp.marginEnd = if (isDP)SizeUtils.dp2px(this.context,end.toFloat()) else end
|
||||
}
|
||||
|
||||
if (bottom != null) {
|
||||
lp.bottomMargin = if (isDP)SizeUtils.dp2px(this.context,bottom.toFloat()) else bottom
|
||||
}
|
||||
this.layoutParams = lp
|
||||
}
|
||||
}
|
||||
|
||||
if (top != null) {
|
||||
lp.topMargin = if (isDP)SizeUtils.dp2px(this.context,top.toFloat()) else top
|
||||
}
|
||||
|
||||
if (end != null) {
|
||||
lp.marginEnd = if (isDP)SizeUtils.dp2px(this.context,end.toFloat()) else end
|
||||
}
|
||||
|
||||
if (bottom != null) {
|
||||
lp.bottomMargin = if (isDP)SizeUtils.dp2px(this.context,bottom.toFloat()) else bottom
|
||||
}
|
||||
this.layoutParams = lp
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user