fix: bugfix

This commit is contained in:
eggmanQQQ
2024-12-04 18:55:01 +08:00
parent 257e40cb32
commit 5f72425b85
17 changed files with 567 additions and 476 deletions

View File

@@ -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
}