Some Android development extensions.

ViewExt

//Sets the padding
fun View.setPaddingLeft(value: Int) 
fun View.setPaddingRight(value: Int)
fun View.setPaddingTop(value: Int)
fun View.setPaddingBottom(value: Int)
fun View.setPaddingStart(value: Int)
fun View.setPaddingEnd(value: Int)
fun View.setPaddingHorizontal(value: Int)
fun View.setPaddingVertical(value: Int)

//Set the width of high
fun View.setWidth(value: Int)
fun View.setHeight(value: Int)
fun View.resize(width: Int.height: Int)

//Set Width and Height (animation)
fun View.animateWidth(toValue: Int.duration: Long.interpolator: Interpolator)
fun View.animateWidthBy(toValue: Int.duration: Long.interpolator: Interpolator)
fun View.animateHeight(toValue: Int.duration: Long.interpolator: Interpolator)
fun View.animateHeightBy(toValue: Int.duration: Long.interpolator: Interpolator)

//mobile
fun View.animateX(toValue: Int.duration: Long.interpolator: Interpolator)
fun View.animateXBy(toValue: Int.duration: Long.interpolator: Interpolator)
fun View.animateY(toValue: Int.duration: Long.interpolator: Interpolator)
fun View.animateYBy(toValue: Int.duration: Long.interpolator: Interpolator)

//ViewGroup child View
val ViewGroup.children: List<View>

//The underline
fun TextView.underLine(a)//In the line
fun TextView.deleteLine(a)//bold
fun TextView.bold(a)//Click on the
fun View.click(block: (View) -> Unit)
fun View.longClick(block: (View) -> Boolean)

//According to
fun View.visiable(a)fun View.invisiable(a)fun View.gone(a)Copy the code

DisplayExt

//Screen size, density
val screenWidth: Int
val screenHeight: Int
val screenDensity: Float
val scaledDensity: Float

fun dp2px(dp: Number)
fun sp2px(sp: Number)
fun px2dp(px: Number)
fun px2sp(px: Number)Copy the code

StringExt

fun String.toast(a)fun String.md5(a)fun String.sha1(a)//Id card or not
fun String.isIdcard(a)//Is it your phone number?
fun String.isPhone(a)//Email address
fun String.isEmail(a)//Case comparison is not considered
fun String.equalsIgnoreCase(other: String)Copy the code

ManagerExt

//Direct call
val connectivityManager
val alarmManager
val telephonyManager
val activityManager
val notificationManager
val appWidgetManager
val inputMethodManager
val clipboardManager
val bluetoothManager
val audioManager
val batteryManagerCopy the code

SpannableExt

//Changes the size of individual fonts in strings
fun spannableSize(text: String.textSize: Int.isDip: Boolean.start: Int.end: Int)
//Individual fonts in the string are bolded
fun spannableBold(text: String.start: Int.end: Int)
//Changes the color of individual fonts in a string
fun spannableColor(text: StringThe @ColorRes colorId: Int.start: Int.end: Int)Copy the code

use

//Initialize the
Ext.with(application)Copy the code