点我跳转到GitHub
android
implementation 'com.ayvytr:ktx:3.0.0' 复制代码
androidx
implementation 'com.ayvytr:ktx-androidx:3.0.0' 复制代码
修改dp,sp,px转换功能,摆脱依赖Context调用,提供Int,Float扩展属性进行dp,sp,px转换,且统一返回Int类型的扩展属性:.dp, .sp, .dp2px, sp2px, px2dp, px2sp
增加ActivityStack,可以实现打开和关闭指定Activity,关闭所有Activity,关闭除指定Activity外所有Activity,终止进程等功能.
增加Spanner工具类,为TextView提供简单易用的SpannableString相关操作
精简工具类 增加Fragment getStringArray等方法
//点击监听:默认是单击事件,防止重复点击时长间隔:millisecondInterval,默认500ms。可修改doActionAfterTimes的值响应多击事件 view.onClick(doActionAfterTimes=1, millisecondInterval=500){ //点击action } //文本变化监听:延迟timeout毫秒触发action,默认timeout=300ms,默认ignoreEmpty=true,空字符串不触发action editText.textChange(timeout=300, ignoreEmpty = true){ //搜索action } 复制代码
getConnectivityManager isNetworkConnected isWifiConnected isMobileDataConnected 复制代码
Int.dp Int.sp Float.dp Float.sp Int.dp2px Float.dp2px Int.sp2px Float.sp2px Int.px2dp Float.px2dp Int.px2sp Float.px2sp 复制代码
registerCallback() unregisterCallback() getRunningActivityCount() isForeground() getCurrentActivity() finish() finishCurrent() finishAll() finishAllExcept() start() startAndFinishOthers() finishExceptTop() forceClose() 复制代码
bold italic normal boldItalic font strikethrough underline backgroundColor backgroundColorRes textColorRes textColor pressedBackgroundColor pressedBackgroundRes onClick onLongClick 复制代码
val clipboardManager = getClipboardManager() clibboardManager.getText2() clibboardManager.setText2() clibboardManager.getUri() clibboardManager.setUri() clibboardManager.getIntent() clibboardManager.setIntent() 复制代码
Context.getStatusBarHeight() Context.inflate(...) //RecyclerView 子 item加载的方法 Context.inflateRv(...) 复制代码
context.getAccountManager() context.getInputMethodManager() context.getConnectivityManager ... 复制代码
context.getStringArray() //方法名称最后包含数字2的是和原生SDK中弃用的或者有版本限制的方法区分开来 context.getDrawable2() context.getColor2() context.getDrawableArray() context.getDrawableIdArray() ... 复制代码
context.getDisplayMetrics() context.isLandscape() context.setLandscape() context.getScreenWidth() context.getScreenHeight() 复制代码
context.toast(...) context.toastLong(...) 复制代码
activity.showActionBar activity.hideActionBar activity.getContext activity.fullscreen(boolean) ... 复制代码
view.show() view.hide() view.invisible() view.isShow() 复制代码
// 设置EditText文本,并且移动光标到文本末尾
editText.setText2(...)
// 设置EditText文本,并且全选文字 editText.setTextWithSelection(...) 复制代码