
Kotlin
小码农·李
这个家伙很懒,还没添加简介·个人
展开
-
把视图保存为图片
把当前视图保存为图片1. 计算视图布局大小SaveViewAsBitmapUtils.kt fun layoutView(v: View, width: Int, height: Int) { val measuredWidth = View.MeasureSpec.makeMeasureSpec( width, View.MeasureSpec.EXACTLY ) val measuredHeight =原创 2022-04-24 19:05:44 · 429 阅读 · 0 评论 -
Android 设置EditText的imeOptions属性无效
Android EditText获取焦点后,输入法右下角换行按钮自定义1、查看系统 imeOptions 属性 <attr name="imeOptions"> <flag name="normal" value="0x00000000" /> <flag name="actionUnspecified" value="0x00000000" /> <flag name="actionNone" value=原创 2021-05-10 10:42:19 · 523 阅读 · 1 评论 -
ConstraintLayout 布局设置margin负值无效解决办法
ConstraintLayout 设置 margin 为负值的时候,并不能像其他布局,如相对布局那样使用(TMD)不知道为什么,用什么辅助实现?Space 对,用这个来,撸码<layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.原创 2021-03-26 17:08:05 · 4922 阅读 · 1 评论 -
Kotlin 属性代理 + SharePreference
“一行代码” 搞定 SharePreferenceprivate var isBlockAll: Boolean by PreferenceDelegate(SpConstant.SP_BLOCK_ALL, false) //屏蔽所有//打印值loggerd("isBlockAll: $isBlockAll")if (isBlockAll) { ...} else { ...}哇,一行代码,感觉针不错!现在你就可以操作Sp存储的字段了具体实现代码import android.c原创 2021-03-24 11:31:17 · 644 阅读 · 0 评论 -
kotlin 循环 forEach 的 continue 和 break
....kotlin 循环 forEach 的 continuelistOf(1, 2, 3, 4, 5).forEach { if (it == 3) return@forEach print(it)}kotlin 循环 forEach 的 breakrun outside@{ (0..10).forEachIndexed { index, it -> println("-- forEach -- ${index} --") if (it > 5) ret原创 2021-03-01 15:23:53 · 857 阅读 · 0 评论