|
|
@ -131,59 +131,83 @@ fun View.setPaddingBottom(padding: Int) { |
|
|
|
this.setPadding(paddingLeft, paddingTop, paddingRight, padding) |
|
|
|
this.setPadding(paddingLeft, paddingTop, paddingRight, padding) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun newLayoutParams(width: Int = ViewGroup.MarginLayoutParams.WRAP_CONTENT, height: Int = ViewGroup.MarginLayoutParams.WRAP_CONTENT): ViewGroup.LayoutParams { |
|
|
|
fun newWWLayoutParams(): ViewGroup.LayoutParams { |
|
|
|
return ViewGroup.LayoutParams(width, height) |
|
|
|
return ViewGroup.LayoutParams(ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun newMarginLayoutParams(width: Int = ViewGroup.MarginLayoutParams.WRAP_CONTENT, height: Int = ViewGroup.MarginLayoutParams.WRAP_CONTENT): ViewGroup.MarginLayoutParams { |
|
|
|
fun newWMLayoutParams(): ViewGroup.LayoutParams { |
|
|
|
return ViewGroup.MarginLayoutParams(width, height) |
|
|
|
return ViewGroup.LayoutParams(ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.MATCH_PARENT) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun View.setTopMargin(topMargin: Int) { |
|
|
|
fun newMWLayoutParams(): ViewGroup.LayoutParams { |
|
|
|
|
|
|
|
return ViewGroup.LayoutParams(ViewGroup.MarginLayoutParams.MATCH_PARENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun newMMLayoutParams(): ViewGroup.LayoutParams { |
|
|
|
|
|
|
|
return ViewGroup.LayoutParams(ViewGroup.MarginLayoutParams.MATCH_PARENT, ViewGroup.MarginLayoutParams.MATCH_PARENT) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun newWWMarginLayoutParams(): ViewGroup.MarginLayoutParams { |
|
|
|
|
|
|
|
return ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun newWMMarginLayoutParams(): ViewGroup.MarginLayoutParams { |
|
|
|
|
|
|
|
return ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.MATCH_PARENT) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun newMWMarginLayoutParams(): ViewGroup.MarginLayoutParams { |
|
|
|
|
|
|
|
return ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams.MATCH_PARENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun newMMMarginLayoutParams(): ViewGroup.MarginLayoutParams { |
|
|
|
|
|
|
|
return ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams.MATCH_PARENT, ViewGroup.MarginLayoutParams.MATCH_PARENT) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun View.setTopMargin(topMargin: Int, layoutParamsCreator: (() -> ViewGroup.MarginLayoutParams)? = null) { |
|
|
|
val params: ViewGroup.LayoutParams? = layoutParams |
|
|
|
val params: ViewGroup.LayoutParams? = layoutParams |
|
|
|
if (params is ViewGroup.MarginLayoutParams) { |
|
|
|
if (params is ViewGroup.MarginLayoutParams) { |
|
|
|
params.topMargin = topMargin |
|
|
|
params.topMargin = topMargin |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
layoutParams = newMarginLayoutParams().apply { |
|
|
|
layoutParams = layoutParamsCreator?.invoke() ?: newWWMarginLayoutParams().apply { |
|
|
|
this.topMargin = topMargin |
|
|
|
this.topMargin = topMargin |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun View.setBottomMargin(bottomMargin: Int) { |
|
|
|
fun View.setBottomMargin(bottomMargin: Int, layoutParamsCreator: (() -> ViewGroup.MarginLayoutParams)? = null) { |
|
|
|
val params: ViewGroup.LayoutParams? = layoutParams |
|
|
|
val params: ViewGroup.LayoutParams? = layoutParams |
|
|
|
if (params is ViewGroup.MarginLayoutParams) { |
|
|
|
if (params is ViewGroup.MarginLayoutParams) { |
|
|
|
params.bottomMargin = bottomMargin |
|
|
|
params.bottomMargin = bottomMargin |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
layoutParams = newMarginLayoutParams().apply { |
|
|
|
layoutParams = layoutParamsCreator?.invoke() ?: newWWMarginLayoutParams().apply { |
|
|
|
this.bottomMargin = bottomMargin |
|
|
|
this.bottomMargin = bottomMargin |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun View.setLeftMargin(leftMargin: Int) { |
|
|
|
fun View.setLeftMargin(leftMargin: Int, layoutParamsCreator: (() -> ViewGroup.MarginLayoutParams)? = null) { |
|
|
|
val params: ViewGroup.LayoutParams? = layoutParams |
|
|
|
val params: ViewGroup.LayoutParams? = layoutParams |
|
|
|
if (params is ViewGroup.MarginLayoutParams) { |
|
|
|
if (params is ViewGroup.MarginLayoutParams) { |
|
|
|
params.leftMargin = leftMargin |
|
|
|
params.leftMargin = leftMargin |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
layoutParams = newMarginLayoutParams().apply { |
|
|
|
layoutParams = layoutParamsCreator?.invoke() ?: newWWMarginLayoutParams().apply { |
|
|
|
this.leftMargin = leftMargin |
|
|
|
this.leftMargin = leftMargin |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun View.setRightMargin(rightMargin: Int) { |
|
|
|
fun View.setRightMargin(rightMargin: Int, layoutParamsCreator: (() -> ViewGroup.MarginLayoutParams)? = null) { |
|
|
|
val params: ViewGroup.LayoutParams? = layoutParams |
|
|
|
val params: ViewGroup.LayoutParams? = layoutParams |
|
|
|
if (params is ViewGroup.MarginLayoutParams) { |
|
|
|
if (params is ViewGroup.MarginLayoutParams) { |
|
|
|
params.rightMargin = rightMargin |
|
|
|
params.rightMargin = rightMargin |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
layoutParams = newMarginLayoutParams().apply { |
|
|
|
layoutParams = layoutParamsCreator?.invoke() ?: newWWMarginLayoutParams().apply { |
|
|
|
this.rightMargin = rightMargin |
|
|
|
this.rightMargin = rightMargin |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun View.setRightMargins(leftMargin: Int, topMargin: Int, rightMargin: Int, bottomMargin: Int) { |
|
|
|
fun View.setMargins(leftMargin: Int, topMargin: Int, rightMargin: Int, bottomMargin: Int, layoutParamsCreator: (() -> ViewGroup.MarginLayoutParams)? = null) { |
|
|
|
val params: ViewGroup.LayoutParams? = layoutParams |
|
|
|
val params: ViewGroup.LayoutParams? = layoutParams |
|
|
|
if (params is ViewGroup.MarginLayoutParams) { |
|
|
|
if (params is ViewGroup.MarginLayoutParams) { |
|
|
|
params.rightMargin = rightMargin |
|
|
|
params.rightMargin = rightMargin |
|
|
@ -191,7 +215,7 @@ fun View.setRightMargins(leftMargin: Int, topMargin: Int, rightMargin: Int, bott |
|
|
|
params.bottomMargin = bottomMargin |
|
|
|
params.bottomMargin = bottomMargin |
|
|
|
params.topMargin = topMargin |
|
|
|
params.topMargin = topMargin |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
layoutParams = newMarginLayoutParams().apply { |
|
|
|
layoutParams = layoutParamsCreator?.invoke() ?: newWWMarginLayoutParams().apply { |
|
|
|
this.rightMargin = rightMargin |
|
|
|
this.rightMargin = rightMargin |
|
|
|
this.leftMargin = leftMargin |
|
|
|
this.leftMargin = leftMargin |
|
|
|
this.bottomMargin = bottomMargin |
|
|
|
this.bottomMargin = bottomMargin |
|
|
|